sudo /usr/local/mysql/support-files/mysql.server stop
2) Start it in safe mode 用安全模式进入mysql 这一步可以看成是不输入密码就进入mysql命令行
sudo mysqld_safe --skip-grant-tables
3) Open another terminal and run the following command (Keep last terminal open) 在另一个窗口中进入mysql
mysql -u root
4) Run the following command with suitable new password on the mysql console 修改密码
mysql > UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
5) mysql > FLUSH PRIVILEGES; 刷新一下缓存