10MySQL数据库安装

一卷旌收千骑虏,万全身出百重围。这篇文章主要讲述10MySQL数据库安装相关的知识,希望能为你提供帮助。
(1)二进制安装mysql 5.7
1)下载MySQL包文件并解压:

[root@localhost ~]# tar xf mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz -C /usr/local
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ln -sv mysql-5.7.33-linux-glibc2.12-x86_64 mysql

2)添加mysql用户:
[root@localhost ~]# groupadd mysql & & useradd -r -g mysql mysql

3)数据库初始化:
[root@localhost local]# chown -R mysql:mysql /usr/local/mysql
[root@localhost local]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

4)编写数据库配置文件:vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
socket=/var/lib/mysql/mysql.sock
port = 3306
user=mysql
# Disablingsymbolic-links is recommended to prevent assorted security risks
symbolic-links=0


【10MySQL数据库安装】[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid


[client]
port=3306
socket=/var/lib/mysql/mysql.sock


5)准备服务文件:
[root@localhost local]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost local]# chmod 755 /etc/init.d/mysqld
[root@localhost local]# chkconfig --add mysqld
[root@localhost local]# chkconfig mysqld on
[root@localhost local]# chkconfig --list

6)数据库启动:
[root@localhost local]# service mysqld start

7)添加环境变量:
[root@localhost local]# vim /etc/profile
export PATH=$PATH:/usr/local/mysql/bin

[root@localhost local]# source /etc/profile

8)数据库安全配置:
[root@localhost local]# /usr/local/mysql/bin/mysql_secure_installation

?
?

    推荐阅读