登录mysql mysql -u root -p 或 mysql
use mysql;
update user set authentication_string=PASSWORD("密码") where user='root';
update user set plugin="mysql_native_password";
flush privileges;
quit;
重启service mysql restart,即可实现密码登录
参考:
https://www.jianshu.com/p/37f823e45496