当前位置:Gxlcms > 数据库问题 > linux 安装mysql 8

linux 安装mysql 8

时间:2021-07-01 10:21:17 帮助过:43人阅读

//这里输入日志里的临时密码,回车,进入mysql mysql> set global validate_password_policy=0; ERROR 1193 (HY000): Unknown system variable validate_password_policy mysql> set global validate_password.policy=0; Query OK, 0 rows affected (0.01 sec) mysql> set global validate_password.length=1; Query OK, 0 rows affected (0.00 sec) mysql> ALTER USER root@localhost IDENTIFIED BY 123456; Query OK, 0 rows affected (0.01 sec)
---------------------------------------------------

解释:下面两行命令,是为了可以设置简单形式的密码

set global validate_password.policy=0; 

set global validate_password.length=1;

然后将密码改为123456:ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘123456‘;

 

如果是5.7版的mysql,命令则是:     

mysql>  set global validate_password_policy=0;

mysql> set global validate_password_length=1;

  -----------------------------------------------------

   查看root用户的加密方式和被允许登录的主机

mysql> select user, host, plugin, authentication_string from user\G;
*************************** 1. row ***************************
user: mysql.infoschema
host: localhost
plugin: caching_sha2_password
authentication_string: $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED
*************************** 2. row ***************************
user: mysql.session
host: localhost
plugin: caching_sha2_password
authentication_string: $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED
*************************** 3. row ***************************
user: mysql.sys
host: localhost
plugin: caching_sha2_password
authentication_string: $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED
*************************** 4. row ***************************
user: root
host: localhost
plugin: caching_sha2_password
authentication_string: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9

 

   解释:

host: localhost  #只允许本机登录root,如果原创要访问,需要开启远程访问才行
plugin: caching_sha2_password  #8.0版本新的加密方式,navicat客户端不支持这种方式,如果远程用navicat客户端连接,需要修改会老版本的加密方式

 

开启root用户可以远程访问操作

#更改加密方式:

mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘password‘ PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)

#更改root密码

mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘123456‘;
Query OK, 0 rows affected (0.17 sec)

#开启root被远程访问

mysql> update user set host = ‘%‘ where user = ‘root‘;
Query OK, 1 row affected (0.09 sec)
Rows matched: 1 Changed: 1 Warnings: 0

#刷新

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

#查看数据库中的各账号信息,可以看到root用户允许任意主机访问%,且加密方式和老版本的一样用 mysql_native_password

mysql> select user, host, plugin, authentication_string from user;
+------------------+-----------+-----------------------+------------------------------------------------------------------------+
| user | host | plugin | authentication_string |
+------------------+-----------+-----------------------+------------------------------------------------------------------------+
| root | % | mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| mysql.infoschema | localhost | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.session | localhost | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.sys | localhost | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
+------------------+-----------+-----------------------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)

技术图片

 

 

 

linux 安装mysql 8

标签:下载页面   更改   允许   ring   随机   with   mysql   访问   sha   

人气教程排行