mysql-5.7.22-linux-glibc2.12安装流程

时间:2021-11-08 06:55:24

在安装过程中可能会报libaio缺失,所以提前安装:yum install libaio

安装流程:

1、在官网上下载mysql-5.7.22-linux,我下载的是mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz。
2、解压tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
3、移动目录mv mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/mysql/mysql-5.7.22
4、创建用户组和用户
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
chown -R mysql:mysql mysql
5、安装mysql
bin/mysqld –initialize –user=mysql –basedir=/usr/local/mysql/mysql-5.7.22/ –datadir=/usr/local/mysql/mysql-5.7.22/data
注意重点记录最后生成的登录密码
6、修改配置
bin/mysql_ssl_rsa_setup –datadir=/usr/local/mysql/mysql-5.7.22/data
vi /etc/my.cnf
cat /etc/my.cnf 修改结果:
[mysqld]
basedir=/usr/local/mysql/mysql-5.7.22
datadir=/usr/local/mysql/mysql-5.7.22/data/
7、配置环境变量
vi ~/.bash_profile
将mysql的bin目录配置到环境变量中
PATH= P A T H : HOME/bin:/usr/local/mysql/mysql-5.7.22/bin
export PATH
8、修改密码
mysql -uroot -p
set password=password(“新密码”);
9、配置远程访问
use mysql
update user set host=’%’ where user=’root’;
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘……’ WITH GRANT OPTION;(或者是:grant all privileges on . to root@’%’ identified by “你的新密码”;)
FLUSH PRIVILEGES;
10、设置开机自启
cd /usr/local/mysql/mysql-5.7.22/support-files
cp mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig –add mysql
chkconfig –list mysql
到此为止,mysql就安装完成,并且可以远程访问了
如果远程访问失败,请查看错误原因,比如防火墙未开启相应端口