2012-11-01 96 views
3

爲根@本地無法訪問某些數據庫是根,剛剛創建的數據庫

mysql> CREATE USER 'aaa'@'%'; 
Query OK, 0 rows affected (0.00 sec) 

mysql> GRANT USAGE ON * . * TO 'aaa'@'%' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; 
Query OK, 0 rows affected (0.00 sec) 

mysql> CREATE DATABASE IF NOT EXISTS `aaa` ; 
Query OK, 1 row affected (0.00 sec) 

mysql> FLUSH PRIVILEGES; 
Query OK, 0 rows affected (0.00 sec) 

mysql> GRANT ALL PRIVILEGES ON `aaa` . * TO 'aaa'@'%'; 
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'aaa' 

是怎麼回事..爲什麼它給我的錯誤後?

mysql> show grants; 
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
| Grants for [email protected]                                                                                              | 
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
| 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 ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*B67132C4A56F2FFFE0AA531DECF0C98895F9CB9B' WITH GRANT OPTION | 
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
1 row in set (0.00 sec) 

回答

1

它沒有足夠的權限。您正試圖授予所有權限。但是,用戶'root'@'localhost'沒有所有權限。

的「SHOW GRANTS」命令outputed的權限列表 - GRANT SELECT, INSERT,...

但它應該是這樣的 - GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'...

首先授予所有的權限root帳戶,或只給予未授予的特權。

+0

你已經得到了在。 我已經恢復了根下面的這一個的所有權限http://stackoverflow.com/questions/1709078/how-can-i-restore-the-mysql-root-users-full-privileges然後它的工作原理。謝謝! – apelliciari

+0

那命令打亂了我的生活 – kamil

4

我已經在過去碰到這種情況,我的解決辦法是明確的,而不是連接到127.0.0.1 localhost的別名

mysql -uroot -h127.0.0.1 

希望對你有用的!

+0

不斷給我同樣的錯誤:( – apelliciari

+0

有一件事我注意到,是你做的創建數據庫如果存在,你有沒有嘗試刪除數據庫,只是爲了清除空氣? – Bryan

+0

是的,我試了很多次..不太好笑! – apelliciari

0

一點點精度在5.7:

mysql -uroot -h127.0.0.1 -p 

GRANT ALL PRIVILEGES ON *.* TO 'root'; 

quit 

然後

mysql -u root -h mynode mydb -p 

工作正常

相關問題