首先先 Kill 掉所有 MySQL 的連線
# on Linux
/etc/init.d/mysqld stop
# on FreeBSD
/usr/local/etc/rc.d/mysql-server stop
killall -9 mysqld
/etc/init.d/mysqld stop
# on FreeBSD
/usr/local/etc/rc.d/mysql-server stop
killall -9 mysqld
mysqld_safe -u root --skip-grant-tables &
mysql
>use mysql
>UPDATE user SET password=password(’這裡輸入你的密碼’) where user=’root’;
>FLUSH PRIVILEGES;
>exit