Centos7中安装Mysql8并修改密码策略并远程连接

安装Mysql8

1、yum仓库下载MySQL:

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

2、yum安装MySQL: 

yum install mysql-community-server

3、启动MySQL服务:

service mysqld start

4、检查MySQL服务状态:

service mysqld status

5、查看初始密码(如无内容直接跳过):

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

 

修改密码策略(在mysql中执行下面命令)
set global validate_password.policy=0;
set global validate_password.length=4;
set global validate_password.check_user_name=OFF;
set global validate_password.number_count=0;
set global validate_password.special_char_count=0;

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';

 

 

 查看当前密码策略(没有修改初始密码时不能查看)
SHOW VARIABLES LIKE 'validate_password%';

 

远程连接:

执行命令为:mysql -u root -p
使用mysql数据库:use mysql;
更改 host 的默认配置
update user set host='%' where user='root';
刷新
flush privileges;

posted @ 2019-05-14 18:50  Jerome27  阅读(1633)  评论(0编辑  收藏  举报