centos7安装mysql8.0
文章创建于 2018-08-15 05:02:10

配置YUM源

下载mysql源安装包

yum localinstall https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

安装mysql

yum install mysql-community-server

启动MySQL服务

systemctl start mysqld

开机启动

systemctl enable mysqld
systemctl daemon-reload

查看默认密码

sudo grep 'temporary password' /var/log/mysqld.log 

链接本地数据库

mysql -uroot -p

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';

重启服务器

service mysqld restart

root用户远程登录

更改加密方式

use mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;

更改密码

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

检查root配置

# root用户登录
mysql -u root -p

# 切换到mysql这个数据库
use mysql;

# 查看root用户配置
select host,user from user where user='root';

修改root配置

update user set host = '%' where user = 'root' and host = '127.0.0.1';

更新配置

FLUSH PRIVILEGES;

重启服务器

service mysqld restart
本文链接