1.关闭数据库mysql
# killall mysqld
2.使用--skip-grant-tables启动mysql,忽略受权登陆验证。sql
# mysqld_safe --skip-grant-tables --user=mysql &
3.登入数据库数据库
# mysql
4.修改密码bash
mysql> update mysql.user set password=password("123456") where user='root' and host='localhost'; mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
5.重启数据库 ide