下载mysql8 安装包
wget http://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum localinstall mysql80-community-release-el7-1.noarch.rpm
下载完成后执行
cd /etc/yum.repos.d/
yum install mysql-community-server
安装完毕后,启动服务器,并且获得初始密码
sudo service mysqld start
grep 'A temporary password' /var/log/mysqld.log
显示:
2019-10-10T10:43:31.881434Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: plGLdU8?Fd=w//密码
mysql -u root -p进入服务器
修改密码和允许外部网络访问mysql
(mysql8.0需要密码大于8位,大小写数字特殊字符)
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'youpassword';
FLUSH PRIVILEGES;
use mysql;
update user set host='%' where user='root';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY ‘youpassword';