ubuntu下
①在/etc/mysql/mysql.conf.d/mysqld.cnf的[mysqld] 模块添加:skip-grant-tables 保存退出。
②service msyql stop和service mysql start重启后msyql服务使配置生效
③执行 mysql -u root -p 登录数据库,提示输入密码时直接敲回车。
选择数据库
use mysql;
将密码置空
update user set authentication_string = '' where user = 'root';
④删掉步骤①的语句skip-grant-tables。重启服务
⑤执行mysql -u root -p登录数据库,提示输入密码时直接敲回车。
alter user 'root'@'localhost' identified by "200423";
后续输入新密码即可登录。
仅供参考