vim /etc/my.cnf
[mysqld]
skip-grant-tables
#重启mysql
systemctl restart mysqld && systemctl status mysqld
#登入mysql#mysql -u root -p123456
mysql -u root -p
use mysql;select host,user from user where user='root';
alter user 'root'@'%localhost' identified by 'LAGWcePJ6#JZ#7';
grant all privileges on *.* to 'root'@'localhost' with grant option;
flush privileges;#报错ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%localhost'#ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
flush privileges;set password for root@localhost=password('LAGWcePJ6#JZ#7');
flush privileges;exit
systemctl restart mysqld && systemctl status mysqld