龙空技术网

如何让MYSQL 8.x 的ROOT用户可以远程登陆

September5 32

前言:

当前看官们对“mysql以root登陆”都比较关注,同学们都需要剖析一些“mysql以root登陆”的相关内容。那么小编在网上搜集了一些对于“mysql以root登陆””的相关内容,希望咱们能喜欢,我们一起来学习一下吧!

通过数据库中user 表,可以发现,默认只有一行,host 部分,值为localhost.

mysql> select host, user, authentication_string, plugin from user where user='root';

+-----------+------------------+------------------------------------------------------------------------+-----------------------+

| host | user | authentication_string | plugin |

+-----------+------------------+------------------------------------------------------------------------+-----------------------+

| localhost | root | *C135C66BA4322B0E07770F6B6F3AED44106C7F6E | mysql_native_password |

如果这个时候,远程使用ROOT登陆,会报如下的错误:

[root@host01 ~]# mysql -uroot -p -h192.168.133.201

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'host01.example.com' (using password: YES)

这个时候,我们可以直接修改USER表

mysql> update user set host='%' where user='root';

不要忘了,把数据库中修改 刷新 到内存中,或者,重启数据库

mysql> flush privileges;

,之后,就可以通过远程登陆了。

标签: #mysql以root登陆