2009年8月4日 星期二

MySQL ERROR 1130

啟動MySQL
/etc/rc.d/init.d/mysqld start

remote connect fail , and get error ERROR 1130
ERROR 1130: Host '192.168.126.1'  is not allowed to connect to this MySQL server

[root@centos5 /]# su - mysql
-bash-3.2$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.0.45 Source distribution

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 |          |
| centos5   | root |          |
| 127.0.0.1 | root |          |
+-----------+------+----------+
3 rows in set (0.01 sec)

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

 

1。 改表法。可能是你的帳號不允許從遠程登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql后,更改 “mysql” 資料庫里的 “user” 表里的 “host” 項,從”localhost”改稱”%”

mysql -u root -p

mysql>use mysql;

mysql>update user set host = ‘%’  where user =’root’;

mysql>flush privileges;

mysql>select ‘host’,'user’ from user where user=’root’;

現在就可以連接了!

2. 授權法。例如,你想myuser使用mypassword從任何主電腦連接到mysql服務器的話。

GRANT ALL PRIVILEGES ON *.* TO‘myuser’@'%’IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;

如果你想允許使用者myuser從ip為192.168.1.3的主電腦連接到mysql服務器,並使用mypassword作為密碼

GRANT ALL PRIVILEGES ON *.* TO‘myuser’@'192.168.1.3′IDENTIFIED BY ‘mypassword’ WITH

沒有留言: