在mysqld.cnf中添加skip-grant-tables
,重启mysql服务
需要先刷新权限,否则不能修改密码。
use mysql; flush privileges; alter user 'root'@'localhost' identified with mysql_native_password by 'abcdefg'; flush privileges;
配置远程登录:
update user set host='%' where user='root'; flush privileges; grant all on *.* to 'root'@'%'; flush privileges;