Home>Article>Web Front-end> MySQL reset Root password on Mac system
This time I will bring you how to reset the Root password for MySQL on the Mac system. What are theprecautionsfor 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
Enter the folder:
cd /usr/local/opt/mysql/bin
Execute unauthorized command (mysql):
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
Use (mysql) to enter the MySQL command :
mysql -u root mysql
Execute change password code:
UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N' WHERE User = 'root' AND Host = 'localhost'; FLUSH PRIVILEGES;
Exit:
quit;
Restart:
brew services restart mysql mysql.server restart
New password login:
mysql -u root -p
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!