(1)mysql 5.7.6以前版本
[mysqld]
skip-grant-tables
systemctl restart mysqld
mysql>update mysql.user set password=password("redhat") where user="root" and host="localhost";
mysql>flush privileges;
#skip-grant-tables
systemctl restart mysqld
(2)mysql 5.7.6以后的版本
[mysqld]
skip-grant-tables
systemctl restart mysqld
mysql> select user,host,authentication_string from mysql.user;
mysql> update mysql.user set authentication_string=password('redhat') where user="root" and host="localhost";
mysql> flush privileges;
#skip-grant-tables
systemctl restart mysqld