-
下载yum源
yum install -y wget wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
-
安装yum源
rpm -ivh mysql80-community-release-el7-5.noarch.rpm
-
安装MySQL
yum install -y mysql-server
-
启动mysql服务
systemctl start mysqld
-
查看root临时密码
grep 'temporary password' /var/log/mysqld.log
-
登录mysql
mysql -uroot -p
-
修改密码 将 root的密码 替换为你要设置的密码
alter user 'root'@'localhost' identified by 'root的密码';
-
开启远程登录
use mysql ; update user set host = '%' where user = 'root'; FLUSH PRIVILEGES;
-
重启数据库
service mysqld restart 或 systemctl restart mysqld