程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> ERROR 1045 (28000): Access denied for user root@localhost

ERROR 1045 (28000): Access denied for user root@localhost

編輯:MySQL綜合教程

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)解決   朋友問我問題: m三ysql 升級了 5.0 -- 5.5導入的數據沒問題, grant all privileges on *.* to test@'12.12.12.12';報錯ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 我剛開始懷疑密碼不對,讓他換成grant all privileges on *.* to test@'12.12.12.12' identified by 'xxx'; 也不行 再換成grant all privileges on *.* to test@'12.12.12.12' identified by '';也不行  

mysql> grant all privileges on *.* to test@'12.12.12.12' identified by '';
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

但是執行如下命令成功了
mysql> grant select on *.* to test@'12.12.12.12' identified by '';
Query OK, 0 rows affected (0.01 sec)

 

  我懷疑當前的root帳號權限問題,讓他執行show grants;
[sql] 
mysql> show grants;  
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+  
| Grants for root@localhost                                                                                                                                                                                                                                                                                                                                     |  
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+  
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'root'@'localhost' WITH GRANT OPTION |  
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON `mysql`.* TO 'root'@'localhost'                                                                                                                                                                                                         |  
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION                                                                                                                                                                                                                                                                                                  |  
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+  
3 rows in set (0.00 sec)  

果然問題出來了,因為正常的root帳號權限如下:
[html] 
mysql> show grants;  
+---------------------------------------------------------------------+  
| Grants for root@localhost                                           |  
+---------------------------------------------------------------------+  
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |  
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |  
+---------------------------------------------------------------------+  
2 rows in set (0.00 sec)  
  
mysql>   

 

   他的root帳號沒有all privileges,所以分配別人all的時候就會報錯。 我讓他用mysqladmin重置root帳號試試看
/usr/local/mysql/bin/mysqladmin –u root password ‘’;

 

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved