linux安裝完mysql后,使用程序連接報以上錯誤
解決方法,重新設置密碼,步驟如下
1.先停掉原來的服務
service mysqld stop
2.使用安全模式登陸,跳過密碼驗證
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.配置完成。