mysql>GRANT ALL PRIVILEGES ON shandong.* TO 'demo'@'%'WITH GRANT OPTION //賦予任何主機訪問數據的權限,也可以如下操作 GRANT ALL PRIVILEGES ON shandong.* TO 'demo'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
引用 另外,當用客戶端連接 mysql 時,發現無法連接,看來需要對用戶進行重新授權。操作如下: [root@cicro108 mysql]# bin/mysql -uroot -p -h 127.0.0.1 -A cws3 Enter password: Welcome to the MySQL monitor. Commands end with or /g. Your MySQL connection id is 1863 to server version: 4.1.20-standard Type 'help;' or '/h' for help. Type '/c' to clear the buffer. mysql> grant ALL PRIVILEGES ON *.* to root@"%" identified by "mysql" ; Query OK, 0 rows affected (0.17 sec) 發現這樣更改權限以后,遠程仍然不能連接,但是用下面的操作就可以了。 mysql> grant ALL PRIVILEGES ON *.* to root@"%" identified by "mysql" WITH GRANT OPTION; Query OK, 0 rows affected (0.17 sec) 此刻, root 可以被遠程連接,當然這里建立其他非 root 用戶也可以遠程連接。
方案二: MySQL 1130錯誤解決方法: 通過MySQL-Front或MySQL administrator連接MySQL的時候發生的這個錯誤 ERROR 1130: Host ***.***.***.*** is not allowed to connect to this MySQL server 說明所連接的用戶帳號沒有遠程連接的權限,只能在本機(localhost)登錄。 需更改 MySQL 數據庫里的 user表里的 host項 把localhost改稱%
具體步驟:登陸到MySQL 首先 use MySQL; 按照別人提供的方式update的時候,出現錯誤。 MySQL> update user set host='%' where user = 'root'; ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 然后查看了下數據庫的host信息如下: MySQL> select host from user where user = 'root'; +-----------------------+ | host | +-----------------------+ | % | | 127.0.0.1 | | localhost.localdomain | +-----------------------+ 3 rows in set (0.00 sec) host已經有了%這個值,所以直接運行命令: