https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
环境
- centos7.4
- mysql8.0
准备
- 安装配置mysql的Yum存储库
https://dev.mysql.com/downloads/repo/yum/
# 下载
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
# 安装
yum -y localinstall mysql80-community-release-el7-1.noarch.rpm
# 检查是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
# 检查存储库启用状态(enabled状态)
yum repolist all | grep mysql
# 禁用
yum-config-manager --disable mysql57-community
# 启用
yum-config-manager --enable mysql80-community
安装
yum -y install mysql-community-server
这将安装MySQL服务器(mysql-community-server)的软件包以及运行服务器所需组件的软件包,包括客户端软件包(mysql-community-client),客户端和服务器(mysql-community-common)的常见错误消息和字符集以及共享客户端库(mysql-community-libs) 。
配置
# 启动
service mysqld start
# or
systemctl start mysqld.service
# 查看状态
service mysqld status
# 显示默认root密码
grep 'temporary password' /var/log/mysqld.log
# 登陆
mysql -uroot -p
# 修改密码(重启服务)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'passwd';
密码策略validate_password要求密码至少包含一个大写字母,一个小写字母,一个数字和一个特殊字符,并且总密码长度至少为8个字符。
- 允许远程访问
# 修改主机为 %
update user set host='%' where user= 'root';
# 授权
GRANT ALL ON *.* TO 'root'@'%';
# 刷新
flush privileges;
出现错误
2056 Authentication plugin 'caching_sha2_password' cannot be load
Client does not support authentication protocol requested by server; consider upgrading MySQL client
尝试执行
# 使用原生密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
总结
根绝官网手册执行,遇到问题以后google一下,问题还是很简单的。。。记录,学习!
网友评论