1.停止MySQL的服务
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
2.cd /usr/local/mysql/bin
./mysqld_safe --skip-grant-table
3.新开个终端
也是进入到mysql/bin目录
./mysql -u root mysql
use mysql;
UPDATE user SET Password=PASSWORD('root') where USER='root';
FLUSH PRIVILEGES;
退出 重启服务
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart