1)进入Mysql的配置文件:vi /etc/my.cnf
(2)在配置文件的末尾加上: skip-grant-tables,如:
2、systemctl restart mysqld.service; 重启mysql服务
3、直接mysql -u root -p直接登入。
3、update mysql.user set authentication_string=password('root') where user='root';
flush privileges;刷新权限
quit;退出mysql
4、vi /etc/my.cnf 中去掉 skip-grant-tables
5、重启mysql systemctl restart mysqld.service;
6、以root账户登录 mysql -u root -p 然后enter,输入密码即可
grant all privileges on *.* to root@'%' identified by "root";
update mysql.user set authentication_string=password('Qq881020!~') where user='root';