MAC OS:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

第一步,将mysql服务停止,在mac系统中停止mysql的方式:(三种,根据下载方式进行)

MacPorts:

sudo launchctl unload -w /Library/LaunchDaemons/org.macports.mysql.plist //停止
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql.plist //重启

Homebrew:

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist //停止
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist //重启

 Binary installer:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restar

第二步 mysql --skip-grant-tables 安全模式进入mysql

再进行密码修改:

mysql> SELECT user,host FROM mysql.user;//查看当前mysql用户
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';//设置密码
mysql> FLUSH PRIVILEGES;

第三步:重新启动mysql 

你可能感兴趣的:(MAC OS:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES))