Chinaunix

标题: 解决远程连接MySQL [打印本页]

作者: rac911    时间: 2007-06-22 15:17
标题: 解决远程连接MySQL
环境:
Server1:MYSQL1+AS4
Server2:MYSQL2+AS4
目的:
从Server1连接到Server2上的MYSQL
TNND,尝试了N遍.远程老是连接不上MYSQL,爆错如下:
[root@etc mysql]# mysql -ueagle -p
Enter password:
ERROR 1045 (28000): Access denied for user
[email='eagle'@'localhost']'eagle'@'localhost'[/email]
(using password: YES)
找一篇文章看一下,豁然开朗,并很快解决问题.步骤如下:
Server1上配置:
[root@etc etc]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 58
Server version: 5.0.41-community MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
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 host,user,password from user;
+---------------+-------+-------------------------------------------+
| host          | user  | password                                  |
+---------------+-------+-------------------------------------------+
| localhost     | root  | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| etc           | root  |                                           |
| 127.0.0.1     | root  |                                           |
| 192.168.1.162 | eagle | *A405AB5000F1FB26DD3D3EB259A6E424169B2AEB |
| %             | root  | *D4CECBA84F0A507325CD8AA82FCDE04EA8BE56B0 |
+---------------+-------+-------------------------------------------+
5 rows in set (0.00 sec)
mysql> grant select,update,insert,delete on *.* to
eagle@192.168.1.161
identified by "eagle";
Query OK, 0 rows affected (0.01 sec)
mysql> select host,user,password from user;
+---------------+-------+-------------------------------------------+
| host          | user  | password                                  |
+---------------+-------+-------------------------------------------+
| localhost     | root  | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| etc           | root  |                                           |
| 127.0.0.1     | root  |                                           |
| 192.168.1.162 | eagle | *A405AB5000F1FB26DD3D3EB259A6E424169B2AEB |
| %             | root  | *D4CECBA84F0A507325CD8AA82FCDE04EA8BE56B0 |
| 192.168.1.161 | eagle | *A405AB5000F1FB26DD3D3EB259A6E424169B2AEB |
+---------------+-------+-------------------------------------------+
6 rows in set (0.00 sec)
mysql>

Server2上测试:
[root@rman mysql]# mysql -h 192.168.1.162 -ueagle -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 60
Server version: 5.0.41-community MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>

OK,问题解决!加油,MySQL菜菜鸟快入门了,,,



本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/26381/showart_326466.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2