mysql为root用户开通远程连接权限

基于安全考虑root账户一般只能本地访问,但是在开发过程中可能需要打开root的远程访问权限

主机192.168.122.11上登录mysql为root用户打开远程连接权限(针对192.168.122.0/24网段主机)
mysql> grant all privileges on *.* to root@'192.168.122.%' identified by "123456";
Query OK, 0 rows affected (0.02 sec)

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

在其他主机上远程连接测试
[root@mysql ~]# mysql -h192.168.122.11 -uroot -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.5.25a-log Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| baidu              |
| mysql              |
| newdb              |
| performance_schema |
| song               |
| test               |
+--------------------+
7 rows in set (0.01 sec)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30373263/viewspace-2121224/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30373263/viewspace-2121224/

你可能感兴趣的:(mysql为root用户开通远程连接权限)