【IT168 技術文檔】 今天不知道怎麼了,在windowns 7上安裝mysql,就是不成功,後來沒有辦法去,在http://dev.mysql.com/downloads/mysql/下了個免安裝的版本,解壓後,用是能用了。
給應用測試的人建立了一個測試的資料庫和用戶,奇怪的是,在本地登錄沒事,遠程登錄,無論如何都報10045(28000)錯誤。
1 C:\Windows\system32>mysql -uuism -h 172.16.9.43
2 ERROR 1045 (28000): Access denied for user 『uism』@』172.16.5.20′ (using password:
3 YES)
檢查系統的user表,發現結果如下:
1 mysql> select user ,host ,password from user;
2 +——+———–+——————+
3 | user | host | password |
4 +——+———–+——————+
5 | root | localhost | |
6 | root | 127.0.0.1 | |
7 | | localhost | |
8 | uism | localhost | 16cfa8943c7fb191 |
9 | uism | % | |
10 | uims | % | |
11 +——+———–+——————+
12 6 rows in set (0.00 sec)
用戶在本地登錄是好的,遠程無論如何都不行,不管給不給密碼。查詢網絡發現,需要將user表中那個用戶名為空的用戶幹掉;
1 mysql> delete from user where user is null;
2 Query OK, 0 rows affected (0.00 sec)
3
4 mysql> delete from user where user =」;
5 Query OK, 1 row affected (0.00 sec)
這裡看看,原來這個用戶名還不是null,只是一個空字符串,暈倒。
然後,重新更新下權限,
1 mysql> flush privileges;
2 Query OK, 0 rows affected (0.00 sec)
再在客戶端做連結:
1 C:\Windows\system32>mysql -uuism -h172.16.9.43
2 Welcome to the MySQL monitor. Commands end with ; or \g.
3 Your MySQL connection id is 103
4 Server version: 5.1.47-community MySQL Community Server (GPL)
5
6 Type 『help;』 or 『\h』 for help. Type 『\c』 to clear the current input statement.
7
8 mysql>
Mysql怎麼會有這麼搞笑的問題,哈哈,而且那個用戶的host為%的那個,密碼為空,現在變成了遠程不需要密碼,本地需要密碼,囧!
原文連結:http://www.oracledba.com.cn/blog/?p=606