mysql服務器裝好以後,默認只能在localhost上登錄,如果你要是從另外的IP地址登錄,即使是本機登錄也會出現問題。
mysql -h 192.168.2.48 -u root -pwow8;
ERROR 1130 (00000): Host '192.168.2.48' is not allowed to connect to this MySQL server
查看mysql手冊,1130表示如下
· 錯誤:1130 SQLSTATE: HY000 (ER_HOST_NOT_PRIVILEGED)
消息:不允許將主機'%s'連接到該MySQL服務器。
所以需要在mysql服務器上打開相應的權限,下面幾步可以是root用戶在所有的機器上以wow8登錄
[zhoulei@localhost ~]$ mysql -u root;
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.1.59-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'wow8' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye