Tutorial on resetting the root password of Mac MySQL

Tutorial on resetting the root password of Mac MySQL

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

If you forget your password after installing MySQL for a long time, 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

Go into the folder:

cd /usr/local/opt/mysql/bin

Execute unauthorized command (mysql):

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

Enter the MySQL command using (mysql):

mysql -u root mysql

Execute the change password code:

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

quit:

quit;

Restart:

brew services restart mysql
mysql.server restart

New password login:

mysql -u root -p

Summarize

The above is the tutorial on how to reset the Root password of Mac MySQL introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • The best solution for resetting the root password of MySQL 8.0.23
  • How to reset the root password in Linux mysql-5.6
  • The easiest way to reset mysql root password
  • Solve the problem of resetting the Mysql root user account password
  • Complete steps to reset the root user password in mysql8
  • How to reset the root password in mysql8.0.12
  • MySQL/MariaDB Root Password Reset Tutorial
  • How to reset MySQL root password under Windows
  • Two ways to reset the root password of MySQL database using lnmp
  • How to Reset MySQL or MariaDB Root Password in Linux
  • Tutorial on resetting the root password of MySQL under CentOS
  • How to reset MySQL root password

<<:  Steps for installing MySQL 8.0.16 on Windows and solutions to errors

>>:  Docker learning: the specific use of Container containers

Recommend

Native JS implementation of loading progress bar

This article shares a dynamic loading progress ba...

CSS to achieve the effect of rotating flip card animation

The css animation of the rotating flip effect, th...

Mini Program Recording Function Implementation

Preface In the process of developing a mini progr...

How to force vertical screen on mobile pages

I recently wrote a mobile page at work, which was...

A complete list of commonly used Linux commands (recommended collection)

Table of contents 1. System Information 2. Shutdo...

MySQL installation diagram summary

MySQL 5.5 installation and configuration method g...

Specific use of useRef in React

I believe that people who have experience with Re...

Analysis of the Principle of MySQL Index Length Limit

This article mainly introduces the analysis of th...

Implementation of master-slave replication in docker compose deployment

Table of contents Configuration parsing Service C...

Vue uses mixins to optimize components

Table of contents Mixins implementation Hook func...

Detailed example of using if statement in mysql stored procedure

This article uses an example to illustrate the us...

Detailed explanation of JDBC database link and related method encapsulation

Detailed explanation of JDBC database link and re...