Home  >  Article  >  Database  >  What should I do if I forget my password for mac mysql?

What should I do if I forget my password for mac mysql?

PHPz
PHPzOriginal
2023-04-17 09:48:327773browse

In recent years, Mac computers have been widely used, especially in the Internet industry and development fields, Mac computers have become one of the indispensable tools. In the development process, the MySQL database is also an inevitable link. However, many people will encounter the problem of forgetting their password when operating on the MySQL database. So, next, I will introduce to you how to solve the problem after forgetting the MySQL database password on Mac computer.

1. Password reset through terminal

In the terminal of Mac computer, you can use the following command to reset password:

1. First, stop the MySQL service , execute the following command:

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

2. Then, perform a MySQL reset by skipping the authorization table through the following command:

sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables &

3. Next, perform MySQL operations through the following command:

mysql - u root

4. After entering MySQL, use the following command to change the password:

use mysql;

update user set authentication_string=password('newpassword') where user='root';

Or use the following command:

update mysql.user set password=password('newpassword') where user='root';

Note : "newpassword" is the new password, which can be changed as needed.

5. After the password change is completed, restart the MySQL service through the following command:

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

2. Password reset through third-party tools

In addition to operating through the terminal, you can also use some third-party tools to reset the password. Two commonly used tools are introduced below:

1.MySQL Workbench

MySQL Workbench is a graphical tool officially provided by MySQL to manage MySQL. It does not require special settings to reset the MySQL password. . The specific steps are as follows:

(1) First open MySQL Workbench, and then click "Manage Users and Permissions".

(2) Next, select the MySQL instance and click "Edit", then click "Manage Account".

(3) In the pop-up window, select the user account that needs to be changed, and then click "Change Password".

(4) Enter the new password and restart the MySQL service.

2.Navicat

Navicat is also a very popular MySQL database management tool. Password changes can be made through the following steps:

(1) First, open Navicat and connect to the MySQL database.

(2) Then, after the connection is successful, select the user who needs to change the password, right-click the user name, and select "Change User Password".

(3) Enter the new password in the pop-up window to complete the password change.

In general, forgetting your MySQL password may be a very common problem, and there are relatively many solutions. The problem can be solved using the terminal or various third-party tools, as long as you follow the relevant steps correctly.

The above is the detailed content of What should I do if I forget my password for mac mysql?. 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