Home > Database > Mysql Tutorial > What to do if you forget your MYSQL database password under MAC

What to do if you forget your MYSQL database password under MAC

小云云
Release: 2017-12-08 09:29:11
Original
2509 people have browsed it

Mysql is a relational database. It is often used in daily work. But what should you do when the database is unavailable for a long time or the database password is forgotten under other circumstances? This article mainly introduces the quick solution for forgetting the MYSQL database password under the Mac operating system and teaches you to reset the MYSQ password. It has certain reference value. Interested friends can refer to it. I hope it can help you.

Quick solution for forgotten MYSQL database password under Mac operating system

1. In the system preferences, stop the MYSQL service.;

2. cd/usr/local/ mysql-...../bin

sudo ./mysqld_safe--skip-grant-tables
Copy after login

3. Log in to MySQL;

mysql
Copy after login

4. Leave the password of root user blank;

mysql> update mysql.user set password=‘' whereUser='root'; 
mysql> flush privileges; 
mysql> quit
Copy after login

5. Restart the MySQL service,

6. Add password mysql> mysqladmin -u root -p password 123 Change the password to 123

Another method from netizens:

#step1:

Turn off the mysql service: Apple->System Preferences->Click mysql at the bottom and close the mysql service in the pop-up page (click stop mysql server)

step2:

Enter the terminal and enter: cd /usr/local/mysql/bin/
After pressing Enter, log in with administrator rights sudo su
After pressing Enter, enter the following command to disable the mysql verification function. /mysqld_safe --skip-grant-tables &
After pressing Enter, mysql will automatically restart (the status of mysql in the preferences will change to running)

step3:

Enter the command ./mysql
After pressing Enter, enter the command FLUSH PRIVILEGES;
After pressing Enter, enter the command SET PASSWORD FOR 'root'@ 'localhost' = PASSWORD('your new password');

After completing the above steps, the password has been successfully changed. Now you can use the newly set password to log in to mysql. Everyone, hurry up and give it a try.

Related recommendations:

How to change the MySQL database password?

How to use the command line to change the MySQL database password

How to retrieve the mysql database password if you forget it, personal test available

The above is the detailed content of What to do if you forget your MYSQL database password under MAC. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template