Mysql5.7.27 change root password under mac

Step 1: Apple -> System Preferences -> click mysql at the bottom, close the mysql service

Step 2: Enter the terminal input (cd /usr/local/mysql/bin/) and press Enter

Type (sudo su) and press Enter to gain administrator privileges

Enter (./mysqld_safe --skip-grant-tables &) and press Enter to disable the mysql authentication function, mysql will automatically restart, and the mysql status in the preferences will change to running

 

Step 3: Open a new command window (note!!!!!!)

Execute cd /usr/local/mysql/bin; press Enter

(./mysql) Enter

 

Enter the command (flush privileges;) Don't forget to lose the semicolon

 

Enter the command (set password for 'root'@'localhost' = password('root');) root in password('root') is the new password, set it yourself, don't forget to enter the semicolon

 

So far, the password has been changed successfully and you can log in normally.

Guess you like

Origin blog.csdn.net/taoanbang/article/details/100641294