1. 程式人生 > 實用技巧 >MySql 資料庫 SQLException: The user specified as a definer ('root'@'%') does not exist 錯誤原因及解決辦法

MySql 資料庫 SQLException: The user specified as a definer ('root'@'%') does not exist 錯誤原因及解決辦法

MySql 資料庫 SQLException: The user specified as a definer ('root'@'%') does not exist 和

java.sql.SQLException: Access denied for user 'root'@'****' (using password: YES)

錯誤原因及解決辦法

  1、如果已經通過Navicat[資料庫管理工具]連線上了資料庫,執行下面內容:

grant all privileges on *.* to root@'%' identified by '******' //***表示資料庫連線密碼

2、如果Navicat資料庫連線不上資料庫了,使用控制檯修改MySQL許可權

(1).首先使用dos命令進入mysql安裝目錄bin目錄下

(2).在DOS命令視窗輸入mysql -hlocalhost -uroot -p回車進入mysql資料庫,

其中-h表示伺服器名,localhost表示本地;

-u為資料庫使用者名稱,root是mysql預設使用者名稱;

-p為密碼,如果設定了密碼,可直接在-p後連結輸入,如:-p123456,使用者沒有設定密碼,顯示Enter password時,直接回車即可。如有密碼輸入密碼後回車

 (3).執行命令 :grant all privileges on *.* to root@'%' identified by '******' //***表示資料庫連線密碼

  出現 Query OK, 0 rows affected (0.00 sec)即可