mysql報錯Accessdeniedforuser'root'@'localhost'(usingpassword:YES)
java.sql.SQLException: Access denied for user `root`@`localhost` (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:943)
上面是錯誤的部分日誌,如果出現了這個錯誤,
首先,保證你連線資料庫的使用者名稱密碼都正確
其次,修改密碼(假設你用root登陸),具體步驟如下:
1. 找到 mysql 的啟動配置檔案
windows 下面是 my.ini ,linux 下面叫 my.cnf ,linux下面如果沒有特別指定目錄,則 my.cnf 一般存放於 /etc/ 目錄下面。
2. 修改 mysql 配置檔案
在配置檔案中找到 [mysqld] 一行,在下面新增 skip-grant-tables 後儲存該檔案並退出。
3. 重新啟動 mysql 資料庫
4. 重置 mysql 的 root 密碼
方法一:使用 “ 路徑/mysql -h hostname(你主機的ip地址) -u root mysql” 命令登入 mysql ,執行命令修改密碼:
update user set password=password(`新的密碼`) where user=`root`;
flush privileges;
方法二:使用 “ 路徑/mysqladmin -h hostname -u rootpassword `新的密碼` ”直接重置root的密碼。
5. 再次修改 mysql 配置檔案
將第2步新增的 skip-grant-tables 這句引數刪除。
6. 再次重新啟動 mysql 資料庫
現在你應該可以使用新密碼正常登入了。
PS:我機器按照以上操作可以正常登陸了,但是以前的資料庫都丟失了,就剩下了三個information_schema、mysql、performance_schema,不知道什麼原因
相關文章
- Accessdeniedforuser:'root@localhost'(Usingpassword:YES)localhost
- 啟動報錯:Access denied for user 'root'@'localhost' (using password:YES)localhost
- MySQL系列:Docker安裝 MySQL提示錯誤:Access denied for user'root'@'localhost' (using password:yes)MySqlDockerlocalhost
- 【MySQL】---1045-Access denied for user 'root'@'localhost'(using password :YES)MySqllocalhost
- vue專案中連線MySQL時,報錯ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password:YES)VueMySqlErrorlocalhost
- Linux錯誤 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)LinuxErrorlocalhost
- java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: YES)JavaSQLExceptionlocalhost
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:YES)Errorlocalhost
- mac os x 安裝mysql遇到 Access denied for user ‘root‘@‘localhost‘ (using password: YES)的解決方法MacMySqllocalhost
- linux安裝MySQL出現ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)LinuxMySqlErrorlocalhost
- ubuntu mysql Access denied for user root@localhostUbuntuMySqllocalhost
- 解決mysql“Access denied for user 'root'@'localhost'”MySqllocalhost
- 報錯”ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)”Errorlocalhost
- SQLSTATE[HY000] [1045] Access denied for user ‘root‘@‘localhost‘ (using password: YES)”錯誤的隱藏解決辦法SQLlocalhost
- mysql 1045, "Access denied for user 'root'@'localhost' (using password: NO)"MySqllocalhost
- Mysql 5.7 CentOS Access denied for user 'root'@'localhost'解決方式MySqlCentOSlocalhost
- Mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- 解決mysql"Access denied fot user 'root'@'localhost'"問題MySqllocalhost
- MYSQL解決error: 'Access denied for user 'root'@'localhost' (using password:MySqlErrorlocalhost
- 解決Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- 一看便知linux下mysql報錯ERROR 1044: Access denied for user: '@localhost' to database 'mysql'LinuxMySqlErrorlocalhostDatabase
- Access denied for user 'root'@'localhost' (using password: NO)localhost
- svelte 執行報錯 getaddrinfo ENOTFOUND localhostlocalhost
- MySQL 登入資料庫報錯'ERROR 1045 (28000): Access denied for user'..'@'localhost''MySql資料庫Errorlocalhost
- Ubuntu18.04:mysql:ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘UbuntuMySqlErrorlocalhost
- Could not resolve host: 'localhost 報錯解決辦法localhost
- 報錯:1130-host ... is not allowed to connect to this MySql server 開放mysql遠端連線 不使用localhostMySqlServerlocalhost
- Access denied for user ‘root‘@‘localhost‘問題的解決localhost
- 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:ERROR 1045 (28000):Access denied for user ‘root‘@‘localhost‘ (using password: NO)的方法MySqlErrorlocalhost
- npm run dev 報錯:getaddrinfo ENOTFOUND localhost和解決方法NPMdevlocalhost
- cmake報錯CMake Error: Could not find CMAKE_ROOTError
- MySQL 8.0.13 密碼問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)MySql密碼Errorlocalhost
- MySQL使用普通使用者訪問返回ERROR 1698 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- Navicat遠端連線MySQL 提示1045 - Access denied for user 'root'@'223.74.158.192'(using password:YES)MySql
- ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)Errorlocalhost