远程连接centos7上的MySQL8

1、更改密码限制级别(可跳过)

2、创建远程连接用户

3、修改密码加密方式

4、验证连接

注:以上基于 端口3306已开,mysql 8.0正确安装

1、更改密码限制级别

查询有关密码验证相关参数,

其中length为密码长度,

policy密码检查等级(

0/LOW:只检查长度,

1/MEDIUM:长度、数字、大小写、特殊字符,

2/STRONG:长度、数字、大小写、特殊字符字典文件

mysql> show variables Like 'valida%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password.check_user_name    | ON    |
| validate_password.dictionary_file    |       |
| validate_password.length             | 8     |
| validate_password.mixed_case_count   | 1     |
| validate_password.number_count       | 1     |
| validate_password.policy             | MEDIUM|
| validate_password.special_char_count | 1     |
+--------------------------------------+-------+
7 rows in set (0.00 sec)

 修改

mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.03 sec)

mysql> set global validate_password.length=4;
Query OK, 0 rows affected (0.01 sec)

 修改过后的限制

mysql> show variables Like 'valida%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password.check_user_name    | ON    |
| validate_password.dictionary_file    |       |
| validate_password.length             | 4     |
| validate_password.mixed_case_count   | 1     |
| validate_password.number_count       | 1     |
| validate_password.policy             | LOW   |
| validate_password.special_char_count | 1     |
+--------------------------------------+-------+
7 rows in set (0.00 sec)

2、创建远程连接用户

create user '用户名'@'远程主机ip' identified by '密码';

grant all on *.* to 'denr'@'192.168.1.1';//授权给IP为192.168.1.1的机器用denr用户登录

mysql> create user 'denr'@'192.168.1.1' identified by 'denr';
Query OK, 0 rows affected (0.13 sec)

mysql> grant all on *.* to 'denr'@'192.168.1.1';
Query OK, 0 rows affected (0.02 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

3、修改密码加密方式

alter user '用户名'@'IP地址' identified with mysql_native_password by'密码';

mysql> alter user 'denr'@'192.168.1.1' identified with mysql_native_password by'denr';
Query OK, 0 rows affected (0.12 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

4、验证连接

猜你喜欢

转载自blog.csdn.net/NeiFen/article/details/83580606