日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

MySQL: linux mysql access denied for user ‘root’@’localhost'(using password:YES)

發布時間:2025/3/21 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySQL: linux mysql access denied for user ‘root’@’localhost'(using password:YES) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

linux安裝完mysql后,使用程序連接報以上錯誤

Access denied for user 'root'@'localhost'?(using password:YES)


解決方法,重新設置密碼,步驟如下

1.先停掉原來的服務

service mysqld stop 或者 /etc/init.d/mysql stop

2.使用安全模式登陸,跳過密碼驗證

nohup mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

3.登陸

mysql -uroot mysql

4.修改密碼

mysql > update user set authentication_string = password('123456') where user = 'root' and Host = 'localhost';

5.刷新權限

mysql > flush privileges;

6.重新使用正常模式登陸

#mysql -uroot -p #enter password : 123456

可以正常登陸。

7.執行其他命令:show databases; 如果提示如下錯誤

You must reset your password using ALTER USER statement before executing this statement.

8.重新將密碼設置一遍即可

mysql > set password = password ('123456');

9.配置完成。

?

如果出現 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

若該路徑下存在.sock文件,開啟一下MySQL服務即可,/etc/init.d/mysql start

總結

以上是生活随笔為你收集整理的MySQL: linux mysql access denied for user ‘root’@’localhost'(using password:YES)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。