1、终端用命令mysql -u root -p 登陆本地mysql
2、输入密码后,依次执行
(1)USE mysql;
(2)ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '831015';
(3)FLUSH PRIVILEGES;
root是用户名,localhost是ip地址127.0.0.1都是特指本机,mysql_native_password是旧的密码验证机制,[email protected]是密码,
3、输入exit,退出
注:如果忘记mysql密码,可用mysqladmin -u root password '[email protected]‘命令重置密码,[email protected]是重置过后的密码