本篇文章基于mysql5.6
启停命令
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart
Begin:
- 停止 mysql server.
通常是在 '系统偏好设置' > MySQL > 'Stop MySQL Server' - 打开终端,输入
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
- 打开另一个新终端,输入:
sudo /usr/local/mysql/bin/mysql -u root
// version 5.7
UPDATE mysql.user SET authentication_string=PASSWORD('新密码') WHERE User='root';
// version 5.6
UPDATE mysql.user SET Password=PASSWORD('新密码') WHERE User='root'
- 刷新权限,并退出
FLUSH PRIVILEGES;
\q
- 重新启动