一, 停止 MySQL 程序
/etc/init.d/mysqld stop 或者 kill 杀 MySQL 的进程 id
通过安全模式启动数据库
mysqld_safe --skip-grant-tables --skip-networking &
查看原来数据库密码字段信息
更改密码:
5.6 版本
update MySQL.user set password=PASSWORD('123') where user='root' and host='localhost';
5.7 版本以上
update MySQL.user set authentication_string=PASSWORD('123') where user='oldboy' and host='10.0.0.%';
来源: http://www.bubuko.com/infodetail-2846648.html