vim /etc/my.cnf skip-grant-tablessystemctl restart mysqld mysql -uroot -p # 直接回车即可登录
二、重启数据库,登录数据更新密码
更新密码要符合数据库的密码的要求,否则无法修改
use mysql; update user set authentication_string=password("Aa@987654321") where user="root"; flush privileges;
三、去掉配置重启数据库,登录数据库更新密码
skip-grant-tables # 在/etc/my.cnf里删掉 systemctl restart mysqld # 重启数据库ALTER user 'root'@'localhost' IDENTIFIED BY 'Aa@987654321';# 创建并授权其它的用户账号 GRANT ALL PRIVILEGES ON *.* TO 'pa'@'%' IDENTIFIED BY 'Aa@12345678' WITH GRANT OPTION; flush privileges;