博客园    首页    新随笔    联系   管理    订阅  订阅

Mysql授权root用户远程登录

默认情况下Mysql的root用户不支持远程登录,使用以下命令授权
 
[Charles@localhost ~]$ mysql -uroot -p123
MariaDB [(none)]> use mysql;
 
MariaDB [mysql]> select Host from user;
+-----------+
| Host      |
+-----------+
| 127.0.0.1 |
| ::1       |
| localhost |
+-----------+
3 rows in set (0.00 sec)
现在没有%,所以不能远程登录
 
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
MariaDB [mysql]> FLUSH   PRIVILEGES;
 
MariaDB [mysql]> select Host from user;
+-----------+
| Host      |
+-----------+
| %         |
| 127.0.0.1 |
| ::1       |
| localhost |
+-----------+
4 rows in set (0.00 sec)
posted @ 2018-11-08 16:36  求生的狼  阅读(5075)  评论(0编辑  收藏  举报