Web項目數據庫MySQL出現Access denied for user (using password: YES)報錯的解決辦法

1、分析

Access denied 拒絕訪問

using password: YES密碼正確(No爲錯誤)

2、解決辦法

2.1、不使用密碼直接進入數據庫(不建議使用)

1、打開MySQL的my.ini文件,在文件的最後添加“skip-grant-tables”,保存
2、如果找不到my.ini文件,是因爲隱藏了,輸入%ProgramData%找到隱藏文件
在這裏插入圖片描述
也可以顯示隱藏文件
在這裏插入圖片描述
在mysqlid後面添加skip-grant-tables
在這裏插入圖片描述
保存並關閉後,重啓MySQL,再次運行項目試試

2.2、修改密碼

1、進入數據庫後
2、use mysql;
3、update user set password=PASSWORD(“111111”) where user=‘root’;
但是報錯ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’
更改爲 update mysql.user set authentication_string=password(‘111111’) where user='root’即可
在這裏插入圖片描述
4、刪除my.ini文件的“skip-grant-tables”
5、重啓服務器


問題,密碼修改成功,但是數據庫依然顯示ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)


set password for ‘root’@‘localhost’=password(‘111111’);
但是報錯了。。。。

所以我先不改數據庫的密碼了了,去修改了web項目裏的密碼

driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/newsmanagersystem?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username=root
password=111111

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章