系统基于ubuntu 12.04 server版本
1.先停掉mysql
# sudo /etc/init.d/mysql stop
2.以--skip-grant-table 的參數啟動mysql
# sudo mysqld_safe --skip-grant-table&
3. 更改root 密碼123123
# mysql
mysql> UPDATE user SET password=password('123123') WHERE user='root';
mysql >GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '123123';
mysql> FLUSH PRIVILEGES;
mysql> exit
4.启动mysql
#service mysql restart
大功告成!