Access denied for user ‘root‘@‘localhost‘問題的解決
問題場景
在阿里雲上部署了一臺伺服器,CentOS6.8系統環境,安裝了MySql+Nginx+Git+vsftpd等軟體,在本地Linux終端以非root賬戶SSH遠端登入伺服器,在將專案打包釋出時遇到如題所示問題。程式碼中配置檔案裡的使用者名稱不是“root”,密碼正確,且該使用者名稱和密碼是配置在服務端資料庫的使用者表中的。但是在用瀏覽器呼叫跟資料庫互動介面時出錯:
嘗試解決
網上搜了一堆文章,主要集中在
(1)對root授權:無效
grant all privileges on *.* to root@localhost identified by '你為root設定好的密碼';
flush privileges;
(2)修改root密碼:無效
(3)修改配置:失效
(4)新增host:失效
最終解決
搜了一圈,雖然問題沒解決,但是我也搞懂了就是對root的授權出了問題。
那問題到底出在哪裡?
為什麼別人的方法對我這個情況都不適用?
我跟別人在相同解決方案的情況下有什麼變數不同?
——想清楚了這點,我找到了不同點:我使用的是自己的賬戶SSH遠端登入並進行授權操作
(1)SSH登入root管理員賬戶
(2)登入MySql
# mysql -u root -p
Enter password:
(3)執行授權命令
mysql> grant all privileges on *.* to root@'localhost' identified by '密碼';
mysql> flush privileges;
或
mysql> grant all privileges on *.* to root@'%' identified by '密碼';
mysql> flush privileges;
(4)退出再試
mysql> quit
Bye
(5)再次登入
然後,問題就解決了~
相關文章
- 解決mysql"Access denied fot user 'root'@'localhost'"問題MySqllocalhost
- 解決mysql“Access denied for user 'root'@'localhost'”MySqllocalhost
- Mysql 5.7 CentOS Access denied for user 'root'@'localhost'解決方式MySqlCentOSlocalhost
- MYSQL解決error: 'Access denied for user 'root'@'localhost' (using password:MySqlErrorlocalhost
- ubuntu mysql Access denied for user root@localhostUbuntuMySqllocalhost
- Access denied for user 'root'@'localhost' (using password: NO)localhost
- 解決Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- ERROR 1045 (28000): Access denied for user 'root'@'localhost'Errorlocalhost
- Error 1045(28000) Access Denied for user 'root'@'localhost'Errorlocalhost
- #1045 - Access denied for user 'root'@'localhost' (using password: NO)localhost
- mysql 1045, "Access denied for user 'root'@'localhost' (using password: NO)"MySqllocalhost
- Mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- 解決Mysql:ERROR 1045 (28000):Access denied for user ‘root‘@‘localhost‘ (using password: NO)的方法MySqlErrorlocalhost
- ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)Errorlocalhost
- 啟動報錯:Access denied for user 'root'@'localhost' (using password:YES)localhost
- java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: YES)JavaSQLExceptionlocalhost
- 【MySQL】---1045-Access denied for user 'root'@'localhost'(using password :YES)MySqllocalhost
- MySQL 8.0.13 密碼問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)MySql密碼Errorlocalhost
- mac os x 安裝mysql遇到 Access denied for user ‘root‘@‘localhost‘ (using password: YES)的解決方法MacMySqllocalhost
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:YES)Errorlocalhost
- 報錯”ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)”Errorlocalhost
- MySQL使用普通使用者訪問返回ERROR 1698 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- Ubuntu18.04:mysql:ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘UbuntuMySqlErrorlocalhost
- vue專案中連線MySQL時,報錯ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password:YES)VueMySqlErrorlocalhost
- SQLSTATE[HY000] [1045] Access denied for user ‘root‘@‘localhost‘ (using password: YES)”錯誤的隱藏解決辦法SQLlocalhost
- Linux錯誤 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)LinuxErrorlocalhost
- SpringBoot中yml配置java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: NOSpring BootJavaSQLExceptionlocalhost
- MySQL系列:Docker安裝 MySQL提示錯誤:Access denied for user'root'@'localhost' (using password:yes)MySqlDockerlocalhost
- 【本人親測 已解決】044 - Access denied for user ‘root‘@‘%‘ to database ‘資料庫名稱‘Database資料庫
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'ErrorlocalhostDatabaseMySql
- ERROR 1044 (42000): Access denied for user 'root'@'%' to databaseErrorDatabase
- linux安裝MySQL出現ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)LinuxMySqlErrorlocalhost
- mysql ERROR 1045 (28000): Access denied for user解決方法MySqlError
- Permission denied: user=root, access=WRITE, inode="/":hadoopuser:supergroup:drwxr-xr-xHadoop
- ERROR 1045 (28000): Access denied for user 'root'@'127.0.0.1' (using password: YES)Error127.0.0.1
- User Get 'Access Denied' with Excel Service WebPartExcelWeb
- MySQL 登入資料庫報錯'ERROR 1045 (28000): Access denied for user'..'@'localhost''MySql資料庫Errorlocalhost
- Access denied for user 'default'@'%' to database 'shop'報錯Database