簡體   English   中英

錯誤1045(28000):用戶'root'@'%'的訪問被拒絕

[英]ERROR 1045 (28000): Access denied for user 'root'@'%'

我正在嘗試跑步

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

從遠程服務器到localhost / phpmyadmin,但收到錯誤1045(28000): Access denied for user 'root'@'%' (using password: NO).

mysql> show grants;
+----------------------------------+
| Grants for root@%                |
+----------------------------------+
| GRANT USAGE ON *.* TO 'root'@'%' |
+----------------------------------+

我該如何解決這個問題? 我已經通過互聯網提出了很多建議,但實際上無法弄清楚。

我認為,您忘記了flush privileges

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' with GRANT OPTION;
mysql> FLUSH PRIVILEGES;

注意:我已將with GRANT OPTION包含在內with GRANT OPTION因為如文檔所述:

使用GRANT OPTION特權,您可以授予其他用戶或從其他用戶中刪除您自己擁有的那些特權。

編輯1:

根據評論,好像您忘記了root密碼。 因此,嘗試像這樣重置:

  1. 停止MySQL服務器。

    sudo /etc/init.d/mysql stop

  2. 在沒有密碼的情況下啟動mysql

    sudo mysqld_safe --skip-grant-tables &

  3. root身份登錄到mysql

    mysql -u root

  4. 將新密碼設置為root

    UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';

  5. 刷新權限。

    FLUSH PRIVILEGES;

  6. 最后,正常重啟mysql。

如果您具有root憑據,則按如下所述設置權限。

將db。*上的所有特權授予“ pass”標識的user @'%';

謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM