Handling Error 1698 During MySQL Login
Users may encounter ERROR 1698 (28000): Access denied for user 'root'@'localhost' when trying to log into the MySQL database with the root user.此錯誤通常在Ubuntu之類的系統上遇到,其中MySQL默認使用UNIX auth_socket插件進行身份驗證。
依賴於系統用戶憑證用於真實。通過查詢mysql.user表,您可以驗證root用戶已在此插件中註冊:選擇用戶,host,host,from MySql.user; 此方法涉及設置root用戶以使用更傳統的mysql_native_password插件:
option 2:創建一個新的數據庫用戶(推薦)SELECT User, Host, plugin FROM mysql.user;使用您的系統用戶名創建新的數據庫用戶。這提供了一個更易於管理,更安全的選項:
創建用戶'your_system_user'@'localhost'由'your_passwd'確定的; 將 *。 *授予'your_system_user'@'localhost'; 更新用戶集插件='auth_socket'其中用戶='your_system_user'; 沖洗特權; sudo service mysql restartNote that with Option 2, you will connect to MySQL using your system username:
mysql -u YOUR_SYSTEM_USER
Additional Considerations:
UPDATE user SET plugin='mysql_native_password' WHERE User='root'; FLUSH PRIVILEGES; sudo service mysql restart
In MySQL versions 8.x.x, the Auth_socket插件可能已被Caching_SHA2_Password替換。請諮詢MySQL文檔,以獲取適當的身份驗證插件和登錄方法。 在debian 9(strention)中,auth_socket插件被重命名為unix_socket。相應地調整sql命令。
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3