2015-12-05 66 views
1

第一步是關閉的MySQL,然後顯示撥款重新連接禁用:試圖修復MySQL的root用戶權限

/Applications/MAMP/Library/bin/mysqld --skip-grant-tables 
--skip-networking --port=3306 --socket=/Applications/MAMP/tmp/mysql/mysql.sock & 

從那裏我連接到MySQL沒有用戶/密碼,就去固定的授予權限:

UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root'; 

所以現在我mysql.user行的樣子:

+-----------+-------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+ 
| Host  | User | Password         | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | plugin | authentication_string | 
+-----------+-------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+ 
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | Y   | Y   | Y   | Y   | Y   | Y   | Y   | Y    | Y   | Y   | Y   | Y    | Y   | Y   | Y   | Y   | Y      | Y    | Y   | Y    | Y    | Y    | Y    | Y     | Y     | Y    | Y   | Y   | Y      |   |   |    |    |    0 |   0 |    0 |     0 |  |      | 
+-----------+-------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+ 

然後我關閉mysql和重啓都授權表選項等:

/Applications/MAMP/Library/bin/mysqld --port=3306 --socket=/Applications/MAMP/tmp/mysql/mysql.sock & 

然後我用root用戶名和密碼重新連接,並再次給予自己的權限來我所有的本地數據庫:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' 

仍然沒有運氣。

mysql> SELECT * FROM exp_throttle LIMIT 1; 
ERROR 1142 (42000): SELECT command denied to user 'root'@'localhost' for table 'exp_throttle' 

我是否缺少明顯的東西?

+0

謝謝瑞恩,我已經閱讀並嘗試過。我甚至無法卸載/重新安裝mysql,因爲我無法獲取數據庫。 – JamesNZ

+0

我放棄了並從我的系統中完全卸載/重新安裝了MAMP Pro,甚至在此之後,root用戶仍然無法做任何事情(即創建一個新的數據庫)。 – JamesNZ

回答

0

更新查詢後,您需要刷新權限

FLUSH PRIVILEGES; 

爲了進一步瞭解您的權限光可以運行

SELECT user() 
SELECT current_user() 

應該有這兩種情況下根@本地。再看看你目前的補助

SHOW GRANTS; 

IF在安全模式下修復權限沒有幫助,嘗試添加其他用戶具有完全權限,並與新的用戶連接到數據庫。

+0

我已經嘗試過在改變權限之前和之後。沒有運氣。 – JamesNZ

+0

然後你需要看看你當前的撥款 顯示撥款 然後運行在安全模式和 授予所有特權* * *'根'@'本地主機'與授予選項 – miholeus

+0

這些是我有的贈款:授予所有權限*。*至'root'@'localhost'由密碼標識'* 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B'WITH GRANT OPTION | |授予'monkey101_db'上的所有特權。* to'root'@'localhost' |在'roll_db'上授予所有特權。* TO'root'@'localhost' | GRANT PROXY ON''@''TO'root'@'localhost'WITH GRANT OPTION – JamesNZ