1. 查看是否有已安装的mysql
yum list installed | grep mysql
2. 删除原有的mysql
yum -y remove 第一步查出的程序名称
3. 添加rpm源
去mysql官网(https://dev.mysql.com/downloads/repo/yum/)找到最新的rpm下载链接:
下载并安装:
wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum localinstall mysql-community-release-el6-5.noarch.rpm
4. 查看并只启用mysql57
yum repolist all | grep mysql
yum-config-manager --disable mysql55-community
yum-config-manager --disable mysql56-community
yum-config-manager --enable mysql57-community-dmr
5. 安装mysql
yum install mysql-community-server
6. 启动mysql服务并设置成开机启动
service mysqld start
chkconfig --list | grep mysqld
chkconfig mysqld on
7. 查看自动生成的临时密码
grep 'temporary password' /var/log/mysqld.log
8. 使用输出的临时密码登陆mysql
mysql -u root -p
9. 关闭密码复杂性验证
mysql> set global validate_password_policy=0;
10. 设置密码
mysql> set password = password('youpassword');
11. 允许用户远程连接
mysql> grant all privileges on *.* to 'root'@'%' identified by 'youpassword' with grant option;
mysql> flush privileges;
mysql> exit;