centos 安装 mysql5.7.9初始密码问题

mysql5.7.9在安装完成后会,root用户会产生一个不为空的初始密码,登陆mysql就会产生问题了,有必要修改一下登陆密码:

这是从网上找的一个方法,加以总结得出来的,亲测可以:
# /etc/init.d/mysql stop 
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & 
# mysql -u root mysql 
mysql>update mysql.user set authentication_string=password('321321') where user='abc' and Host = 'localhost';

mysql> quit 

# /etc/init.d/mysql restart 
# mysql -uroot -p 
Enter password: <输入新设的密码newpassword> 
mysql> 

原文地址:https://www.cnblogs.com/timothy-lai/p/5564740.html