CentOS安装MySQL8 修改密码策略 授权远程访问

安装MySQL

  1. 配置Mysql 8.0安装源
sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
  1. 安装Mysql 8.0
sudo yum --enablerepo=mysql80-community install mysql-community-server
  1. 启动Mysql
sudo service mysqld start
  1. 查看运行状态
service mysqld status

修改密码

  1. 查看临时密码
grep "A temporary password" /var/log/mysqld.log
  1. 登入Mysql
mysql -uroot -p
  1. 修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

修改密码策略

  1. 修改密码最小长度
set global validate_password.length=4;
  1. 修改验证密码的复杂程度
set global validate_password.policy=0;
  1. 关闭用户名检查
set global validate_password.check_user_name=off;
  1. 修改你的密码为root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

授权远程访问

  1. 打开Mysql库
use mysql;
  1. 查看root用户主机信息
select host from user where user='root';
  1. root用户开放给所有主机
update user set host = '%' where user ='root';
  1. 配置生效
flush privileges;

你可能感兴趣的:(CentOS安装MySQL8 修改密码策略 授权远程访问)