Home > Web Front-end > JS Tutorial > MySQL reset Root password on Mac system

MySQL reset Root password on Mac system

php中世界最好的语言
Release: 2018-03-20 09:29:17
Original
2325 people have browsed it

This time I will bring you how to reset the Root password for MySQL on the Mac system. What are the precautions for resetting the Root password for MySQL on the Mac system? The following is a practical case, let’s take a look.

Statement: This password reset can directly reset the password of MySQL installed by Homebrew. For MySQL installed by other methods, you need to switch the corresponding installation directory.

After installing MySQL for too long, you may forget your password. Here is a summary of how to reset the local MySQL Root password when you forget your password.

All operations are completed in the Mac Terminal.

Stop services and processes:

brew services stop mysql
Copy after login

Enter the folder:

cd /usr/local/opt/mysql/bin
Copy after login

Execute unauthorized command (mysql):

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
Copy after login

Use (mysql) to enter the MySQL command :

mysql -u root mysql
Copy after login

Execute change password code:

UPDATE mysql.user
     SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
     WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
Copy after login

Exit:

quit;
Copy after login

Restart:

brew services restart mysql
mysql.server restart
Copy after login

New password login:

mysql -u root -p
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Inheritance and prototype chain of JavaScript

Methods to convert Json and string to each other

The above is the detailed content of MySQL reset Root password on Mac system. 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