Modify the root password of MySQL on MAC


To change the root password after installing MySQL for Mac:

You must stop the MySQL service before starting the following steps!!!!

Open the terminal
1、cd /usr/local/mysql/bin/

2、sudo su
After input, you will be asked to enter your computer password. When entering, nothing will be displayed. Press enter after input
3、 ./mysqld_safe –skip-grant-tables &
The purpose of this step is to cross permission validation

4、./mysql -uroot 

You are logged in as root because you do not need a password for the reason in step 3. After this command, you don’t need to add. / MySQL before it;

5、use mysql;

6、(1) update mysql.user set authentication_ string=password(‘123456’), plugin = ‘mysql_ native_ Password ‘where user =’root’; use this line to explicitly change the root password to 123456.
(2) Flush privileges; application permissions.
(3) Exit and restart mysql.

This step is definitely the most pitiful step! All the versions circulated on the Internet are set password = ‘, so I always report an error that the “password” column does not exist!!!

In the end, only the authentication command can be used_ String field, no password field.

After executing the previous step, I thought I could log in, but during the Navicat connection test, the following appears:

ERROR 1862 (HY000): Your password has expired. To log in you must
change it using a client that supports expired passwords.

So it needs the following two steps (I can log in with the client without the following steps)

Open a new terminal:

1、cd /usr/local/mysql/bin/

2、sudo su

3、./mysql -uroot  -p123456


At this point, the password is modified successfully! User name: root password: 123456

Commands to start and close MySQL service under mac

##Start MySQL service 
sudo /usr/local/MySQL/support-files/mysql.server start 

##Stop MySQL service 
sudo /usr/local/mysql/support-files/mysql.server stop 

##Restart MySQL service 
sudo /usr/local/mysql/support-files/mysql.server restart

Recommended Today

MVC and Vue

MVC and Vue This article was written on July 27, 2020 The first question is: is Vue an MVC or an MVVM framework? Wikipedia tells us: MVVM is a variant of PM, and PM is a variant of MVC. So to a certain extent, whether Vue is MVC or MVVM or not, its ideological direction […]