How to modify the forgotten password when installing MySQL on Mac

How to modify the forgotten password when installing MySQL on Mac

1. Install MySQL database on mac

1. Download MySQL database

Download address: Visit the official website of MySQL at http://www.mysql.com/downloads/ to download.

Enter the MySQL download interface (http://www.mysql.com/downloads/mysql/)

Download the x86, 64bit dmg file: Select "No thanks, just take me to downloads!" at the bottom.

2. Install MySQL database

After opening the MySQL installation package, click to install the main program pkg file.

3. Start the MySQL database

To open the MYSQL database file, open it in System Preferences, click MySQL, start MySQL server, and start MySQL.

4.Terminal log in to MySQL database:

mysql -u root -p

Press Enter. The default password is empty. When password appears, press Enter.

2. After installing the database, I found that I forgot the database password

1. First close the MySQL database

Close MySQL in System Preferences, stop mysql server

2. Enter Safe Mode

? bin sudo su
Password:
Sorry, try again.
Password:
sh-3.2# ./mysqld_safe --skip-grant-tables &
[1] 3477
sh-3.2# 2017-06-27T08:32:37.6NZ mysqld_safe Logging to '/usr/local/mysql-5.7.18-macos10.12-x86_64/data/localhost.err'.
2017-06-27T08:32:37.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.7.18-macos10.12-x86_64/data
sh-3.2#

3. Restart a terminal

~ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

4. Enter the command

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.06 sec)

5. Reset your password

mysql> SET PASSWORD FOR root@'localhost' = PASSWORD('root');
Query OK, 0 rows affected, 1 warning (0.02 sec)

6. Enter the command again

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

The above is the method I introduced to you to change the forgotten password of MySQL installed on Mac. I hope it will be helpful to you. If you have any questions, please leave me a message and I 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:
  • Solution to forgetting the MYSQL database password under MAC
  • Download MySQL 5.7 and detailed installation diagram for MySql on Mac
  • Detailed graphic and text instructions for installing MySQL 5.7.20 on Mac OS
  • Solution to forget password when installing MySQL on Linux/Mac
  • Detailed steps to configure Apache + PHP + MySQL operating environment in Mac OS X
  • What to do if you forget the initial password when installing MySQL on Mac
  • Detailed steps to install mysql5.7.18 on Mac
  • MySQL installation and configuration tutorial for Mac
  • Detailed installation and configuration of MySql on Mac
  • Tutorial on compiling and installing MySQL 5.7.17 from source code on Mac
  • Solution to forgetting mysql password in MAC
  • Configuring MySQL and Squel Pro on Mac

<<:  This article helps you understand PReact10.5.13 source code

>>:  Detailed description of ffmpeg Chinese parameters

Recommend

Provides helpful suggestions for improving website design

<br />Scientifically Design Your Website: 23...

How to block IP and IP range in Nginx

Written in front Nginx is not just a reverse prox...

Node.js makes a simple crawler case tutorial

Preparation First, you need to download nodejs, w...

Summary of ways to implement single sign-on in Vue

The project has been suspended recently, and the ...

Understanding and example code of Vue default slot

Table of contents What is a slot Understanding of...

Understanding and using React useEffect

Table of contents Avoid repetitive rendering loop...

Research on the problem of flip navigation with tilted mouse

In this article, we will analyze the production of...

How to use MySQL limit and solve the problem of large paging

Preface In daily development, when we use MySQL t...

Vue implements a simple magnifying glass effect

This article example shares the specific code of ...

Example steps for using AntV X6 with Vue.js

Table of contents 0x0 Introduction 0x1 Installati...

MYSQL transaction tutorial Yii2.0 merchant withdrawal function

Preface I am a PHP programmer who started out as ...

Implementation of iview permission management

Table of contents iview-admin2.0 built-in permiss...

Summary of various methods of implementing article dividing line styles with CSS

This article summarizes various ways to implement...

The difference between this.$router and this.$route in Vue and the push() method

The official document states: By injecting the ro...