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