1. 下载mysql-5.7.20 wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20-linux-glibc2.12-i686.tar.gz mysql-5.7.21-linux-glibc2.12-i686.tar.gz 2. 检查是否安装mariadb rpm -qa |grep mariadb (查询结果) rpm -e --nodeps (查询结果) 3. 创建mysql用户 groupadd mysql useradd -r -g mysql mysql 4. 创建data目录,作为数据库存储位置 mkdir data s 5. 修改用户权限 chown -R root:root ./ chown -R mysql:mysql ./data 6. 初始化mysql bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data ***报错*** bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory 提示缺少 libaio.so 安装 libaio yum -y install libai* 成功后出现root 用户的临时密码(临时密码) 9T04:44:27.865413Z 1 [Note] A temporary password is generated for root@localhost: %oCgr+R0l5.1 root@localhost: QoWhp;os-4O+ 7. 启动MySQL,并查看是否已启动成功 bin/mysqld_safe --user=mysql & ps -ef |grep mysql 8. 通过初始密码登录MySQL,并修改密码 bin/mysqladmin -uroot -p password 9. 设置开机自启 cp support-files/mysql.server /etc/rc.d/init.d/mysqld chmod +x /etc/rc.d/init.d/mysqld chkconfig --add mysqld chkconfig --list mysqld 10. 修改/etc/init.d/mysqld文件 basedir= mysql路径 datadir= data路径 11. 配置全局环境变量