mysql添加远程用户并授权

 将root扩展权限(mysql8)

1.连接服务器后,操作mysql系统数据库:

命令:mysql -uroot -p密码

           use mysql;

查看用户表权限: select host,user from user;

2.运行下面两句话之后就可以通过root账户远程登陆。

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

        flush privileges;这句表示从mysql数据库的grant表中重新加载权限数据

3.再次查看用户表权限:select host,user from user; 

mysql> use mysql;
Database changed
mysql> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | root             |
+-----------+------------------+
4 rows in set (0.00 sec)

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

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

mysql> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | root             |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
+-----------+------------------+
4 rows in set (0.00 sec)

 

 

查看更多权限相关的资料可参考:https://blog.csdn.net/m1f2c3/article/details/90765420

 

 

相关推荐
©️2020 CSDN 皮肤主题: 创作都市 设计师:CSDN官方博客 返回首页