Solution to forgetting the MYSQL database password under MAC

Solution to forgetting the MYSQL database password under MAC

Quick solution for forgetting MYSQL database password under Mac operating system

1. In System Preferences, stop the MYSQL service.

2. cd /usr/local/mysql-...../bin

sudo ./mysqld_safe --skip-grant-tables

3. Log in to MySQL;

mysql

4. Set the root user's password to blank;

mysql> update mysql.user set password='' whereUser='root'; 
mysql> flush privileges; 
mysql> quit

5. Restart the MySQL service.

6. Add password mysql> mysqladmin -u root -p password 123 Change the password to 123

Another method from netizens:

step1:

Shut down the MySQL service: Apple->System Preferences->Click MySQL at the bottom. In the pop-up page, shut down the MySQL service (click Stop MySQL Server).

step2:

Enter the terminal and type: cd /usr/local/mysql/bin/
After pressing Enter, log in with administrator privileges sudo su
After pressing Enter, enter the following command to disable the mysql authentication function./mysqld_safe --skip-grant-tables &
After pressing Enter, MySQL will automatically restart (the status of MySQL in the preferences will become running)

step3:

Enter the command ./mysql
After pressing Enter, enter the command FLUSH PRIVILEGES;
After pressing Enter, enter the command SET PASSWORD FOR 'root'@'localhost' = PASSWORD('your new password');

After completing the above steps, the password has been changed successfully. Now you can use the newly set password to log in to MySQL.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Teach you how to install mysql database on Mac
  • Solution to the Chinese garbled code problem in Mac Mysql database
  • Sharing of methods of operating MySQL database with PHP under Mac environment
  • Graphic tutorial on installing MySQL database and configuring environment variables on Mac

<<:  Summary of event handling in Vue.js front-end framework

>>:  Nginx reverse proxy configuration removes prefix

Recommend

Nginx service 500: Internal Server Error one of the reasons

500 (Internal Server Error) The server encountere...

Summary of the differences and usage of plugins and components in Vue

The operating environment of this tutorial: Windo...

Vue implements Modal component based on Teleport

Table of contents 1. Get to know Teleport 2. Basi...

MySQL SQL Optimization Tutorial: IN and RANGE Queries

First, let's talk about the in() query. It is...

Detailed steps to expand LVM disk in Linux

1. Add a hard disk 2. Check the partition status:...

How to create a responsive column chart using CSS Grid layout

I have been playing around with charts for a whil...

Why should the number of rows in a single MySQL table not exceed 5 million?

Today, let’s discuss an interesting topic: How mu...

MySQL installation tutorial under Windows with pictures and text

MySQL installation instructions MySQL is a relati...

Details of various font formats in HTML web pages

This section starts with the details of text modi...

Detailed explanation of mkdir command in Linux learning

Table of contents Preface 1. Basic knowledge of f...

A brief discussion on CSS blocking merging and other effects

Non-orthogonal margins When margin is used, it wi...