新安装的mysql首次启动后登录mysql

mysql -u root -h 127.0.0.1  -p

输入的密码请看启动日志:

输入密码后

提示下面错误

ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.

刚启动密码就过期~~~!!!

解决办法

停止mysql

service mysql stop

设置无密码登录

vim /etc/my.cnf
添加:
skip-grant-tables =1 

重启mysql
service mysql start

重新登录mysql

 mysql -u root -h 127.0.0.1  

更新root密码

 user mysql;

update mysql.user set authentication_string=password("123456") where user="root";

停止mysql

删除设置无密码登录

重启mysql

完成

更多推荐