use mysql; ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd'; UPDATE user SET authentication_string ='' WHERE User = 'root';
退出mysql, 删除/etc/my.cnf文件最后的 skip-grant-tables 重启mysql服务; mysql -u root -p无需输入密码即可登入 ALTER user 'root'@'localhost' IDENTIFIED BY 'Qian123#' 远程连接:
1 2 3 4 5 6
use mysql; select user,host from user; update user set host = '%' where user = 'root'; flush privileges; ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; flush privileges;