mysql8开启root的远程访问
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql8开启root的远程访问相关的知识,希望对你有一定的参考价值。
1.查看当前系统的账户
mysql> use mysql;
mysql> select host, user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| localhost | debian-sys-maint |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
5 rows in set (0.00 sec)
2.修改root账户可以远程访问
mysql> update user set host=% where user=root;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> alter user root@% identified with mysql_native_password by 123456;
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
3.查询是否修改成功
mysql> select user,host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| root | % |
| debian-sys-maint | localhost |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
+------------------+-----------+
5 rows in set (0.01 sec)
mysql>
注意:root用户只能是唯一,否则会影响结果直至报错信息一直存在
以上是关于mysql8开启root的远程访问的主要内容,如果未能解决你的问题,请参考以下文章