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

Mini Program to Implement Paging Effect

This article example shares the specific code for...

The difference between html Frame, Iframe and Frameset

10.4.1 The difference between Frameset and Frame ...

mysql 8.0.18 mgr installation and its switching function

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

Detailed explanation of MySQL from getting started to giving up - installation

What you will learn 1. Software installation and ...

A record of pitfalls in JS regular matching

I recently discovered a pitfall in regular expres...

Detailed explanation of the implementation of MySQL auto-increment primary key

Table of contents 1. Where is the self-incremente...

Specific use of pthread_create in linux to create threads

pthread_create function Function Introduction pth...

Detailed explanation of the usage of the alias command under Linux

1. Use of alias The alias command is used to set ...

Ubuntu installation cuda10.1 driver implementation steps

1. Download cuda10.1: NVIDIA official website lin...

In-depth understanding of the vertical-align property and baseline issues in CSS

vertical-align attribute is mainly used to change...

Using zabbix to monitor the ogg process (Linux platform)

The ogg process of a database produced some time ...

Div css naming standards css class naming rules (in line with SEO standards)

There are many tasks to be done in search engine o...

A brief discussion on the use of GROUP BY and HAVING in SQL statements

Before introducing the GROUP BY and HAVING clause...

Detailed steps for debugging VUE projects in IDEA

To debug js code, you need to write debugger in t...

Several methods of implementing carousel images in JS

Carousel The main idea is: In the large container...