天天看點

mysql全局權限賬戶%登入不上ERROR 1045 (28000): Access denied for user 'mhz'@'localhost' (using password: YES) mysql全局權限賬戶%登入不上ERROR 1045 (28000): Access denied for user 'zzq'@'localhost' (using password: YES)

mysql全局權限賬戶%登入不上

error 1045 (28000): access denied for user 'mhz'@'localhost' (using password: yes) 

解決

檢視錯誤提示 

有主機名字的就必須指派主機名

mysql> grant all privileges on *.* to 'mhz'@'mgr2' identified by 'mhz' with grant option;

query ok, 0 rows affected (0.00 sec)

mysql> flush privileges;

query ok, 0 rows affected (0.07 sec)

<a target="_blank" href="http://blog.csdn.net/zzq900503/article/details/15336583">http://blog.csdn.net/zzq900503/article/details/15336583</a>

mysql中有建立了一個%(允許所有主機連接配接)和all權限的賬戶。但是竟然連不上。用root或者其他localhost的使用者卻可以登入。首先檢查下防火牆打開了沒,可以用service iptables stop打開防火牆。如果仍然報錯:

mysql全局權限賬戶%登入不上ERROR 1045 (28000): Access denied for user &amp;#39;mhz&amp;#39;@&amp;#39;localhost&amp;#39; (using password: YES) mysql全局權限賬戶%登入不上ERROR 1045 (28000): Access denied for user 'zzq'@'localhost' (using password: YES)

報錯:error 1045 (28000): access denied for user 'zzq'@'localhost' (using password: yes)

帳号密碼都對了 就是連不上。細心的話我們會發現 帳号權限是%,而這裡提示的是localhost。

錯誤原因如下:

mysql全局權限賬戶%登入不上ERROR 1045 (28000): Access denied for user &amp;#39;mhz&amp;#39;@&amp;#39;localhost&amp;#39; (using password: YES) mysql全局權限賬戶%登入不上ERROR 1045 (28000): Access denied for user 'zzq'@'localhost' (using password: YES)

mysql&gt; grant all privileges on *.* to 'monty'@'localhost'   identified by 'some_pass' with grant option;

mysql&gt; grant all privileges on *.* to 'monty'@'%'      identified by 'some_pass' with grant option;

?6?1 前兩個帳戶名稱都是monty,而且都是擁有所有權限和密碼。但是兩者的差別在于,第一個帳戶(monty@localhost)隻能通過本地登入,而第二個賬戶(monty@%)可以通過任意主機登入。值得注意的是,為了能夠使用monty帳戶在任何地方進行登入,這兩個賬戶同時存在則是必要的。因為,如果沒有本地帳戶(monty@localhost),使用monty帳戶登入時,mysql_install_db将優先考慮建立一個本地的匿名帳戶。那麼結果将是monty賬戶會被當作一個匿名帳戶來處理。原因則在于,匿名帳戶擁有一個比nonty@%賬戶更加具體的host字段值,進而在user表排序的時候會相對出現的更早。

也就是說  同一個賬戶 要同時存在%帳号或者localhost帳号時, %帳号才起作用。

我們給 zzq帳号添加一個localhost帳号。

mysql全局權限賬戶%登入不上ERROR 1045 (28000): Access denied for user &amp;#39;mhz&amp;#39;@&amp;#39;localhost&amp;#39; (using password: YES) mysql全局權限賬戶%登入不上ERROR 1045 (28000): Access denied for user 'zzq'@'localhost' (using password: YES)

grant all privileges on *.* to 'zzq'@'localhost'   identified by '123456' with grant option;

flush privileges;

然後再登入 發現可以登入了。 遠端用workbench也能連接配接了。

這僅僅是通路權限不夠

error 1045 (28000): access denied for user 'xcj'@'localhost' (using password: yes)

#新加使用者服務xcj,新加的使用者不能馬上生效

mysql&gt; grant all on *.* to xcj@'%' identified by "xcj_passwd";

query ok, 0 rows affected (0.04 sec)

#生效新加使用者xcj權限

query ok, 0 rows affected (0.03 sec)

[root@openfire pdf_spider]# mysql -uxcj -p'xcj_passwd' 

welcome to the mysql monitor.  commands end with ; or \g.

your mysql connection id is 4593

server version: 5.0.45-log mysql community server (gpl)

type 'help;' or '\h' for help. type '\c' to clear the buffer.

mysql&gt; 

#若是還不生效,就見鬼了