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

Implementation of Docker private warehouse registry deployment

As more and more Docker images are used, there ne...

CSS to achieve fast and cool shaking animation effect

1. Introduction to Animate.css Animate.css is a r...

Introduction to MySQL overall architecture

The overall architecture of MySQL is divided into...

33 ice and snow fonts recommended for download (personal and commercial)

01 Winter Flakes (Individual only) 02 Snowtop Cap...

Implementation of tomcat deployment project and integration with IDEA

Table of contents 3 ways to deploy projects with ...

Let's talk about the two functions of try catch in Javascript

The program is executed sequentially from top to ...

Steps to install cuda10.1 on Ubuntu 20.04 (graphic tutorial)

Pre-installation preparation The main purpose of ...

Detailed explanation of the functions of each port of Tomcat

From the tomcat configuration file, we can see th...

MySQL 8.0.16 installation and configuration graphic tutorial under macOS

This article shares the installation and configur...

Detailed explanation of CSS3 elastic expansion box

use Flexible boxes play a vital role in front-end...

mysql 8.0.18 mgr installation and its switching function

1. System installation package yum -y install mak...

Some functions of using tcpdump to capture packets in the Linux command line

tcpdump is a flexible and powerful packet capture...