使用mysql遠程連接軟件(MySQL-Front),遠程連接報錯:
[root@master ~]# mysql -u root@localhost
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, 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>quit
解決遠程無法連接:
[root@master ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, 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> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user,password,host from user;
--需要將遠程訪問主機的IP添加進去
+------+-------------------------------------------+-----------------+
| user | password | host |
+------+-------------------------------------------+-----------------+
| root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | localhost |
| root | *D997577481B722A2996B58BCE11EF3C312AC0B89 | master.cloudera |
| root | | 127.0.0.1 |
| | | localhost |
| | | master.cloudera |
+------+-------------------------------------------+-----------------+
5 rows in set (0.00 sec)
mysql> grant all privileges on *.* to root@"10.53.105.221" identified by "root";
--賦予IP地址為10.53.105.221主機擁有所有權限(其中包括遠程訪問、遠程操作權限)
Query OK, 0 rows affected (0.04 sec)
mysql> flush privileges;
--重新加載權限設置
Query OK, 0 rows affected (0.05 sec)
mysql> select user,password,host from user;
--再次查詢,IP為10.53.105.221主機已經添加到host文件中
+------+-------------------------------------------+-----------------+
| user | password | host |
+------+-------------------------------------------+-----------------+
| root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | localhost |
| root | *D997577481B722A2996B58BCE11EF3C312AC0B89 | master.cloudera |
| root | | 127.0.0.1 |
| | | localhost |
| | | master.cloudera |
| root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | 10.53.105.221 |
+------+-------------------------------------------+-----------------+
6 rows in set (0.00 sec)
再次遠程登陸,成功連接了,如下圖: