Home >Database >Mysql Tutorial >mac forgot mysql password

mac forgot mysql password

王林
王林Original
2023-05-18 18:23:38572browse

If you are a Mac user and you have forgotten your MySQL password, then don’t worry, you can reset your MySQL password by following these steps:

  1. Stop MySQL Server

Open the Terminal application and stop the MySQL server using the following command:

sudo /usr/local/mysql/support-files/mysql.server stop

  1. Start the MySQL server and skip Permission verification

Use the following command to start the MySQL server and skip permission verification:

sudo mysqld_safe --skip-grant-tables

Note: Before starting the MySQL server , you will see a lot of screen output. Please do not close the Terminal application.

  1. Log in to the MySQL server and change the password

Open a new terminal application and use the following command to log in to the MySQL server:

mysql -u root

At this point, you have successfully logged into the MySQL server, and you should be able to see the MySQL prompt.

Now you can change your MySQL password using the following command:

UPDATE mysql.user SET Password=PASSWORD('new_password') WHERE User='root';

Please note to replace "new_password" with the new password you want to set.

After changing the password, use the following command to refresh the system permission table:

FLUSH PRIVILEGES;

Finally, use the following command to exit the MySQL server:

quit

  1. Restart the MySQL server

Restart the MySQL server using the following command:

sudo /usr/local/mysql/support-files/mysql. server start

Now, you have successfully changed the MySQL password and can access the MySQL server normally.

The above is the detailed content of mac forgot mysql password. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:mysql table garbled codeNext article:mysql table garbled code