The easiest way to reset mysql root password

The easiest way to reset mysql root password

My mysql version is MYSQL V5.7.9, please use the older version:

UPDATE mysql.user SET Password=PASSWORD('new password') WHERE User='root';

Mac OS X - Reset MySQL Root Password

Too many passwords to remember? ? Have you forgotten your MySQL root password for Mac OS? Follow these 4 steps to reset your password:

1. Stop mysql server.

Usually in 'System Preferences' > MySQL > 'Stop MySQL Server'

2. Open the terminal and enter:

sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables

3. Open another new terminal and enter:

sudo /usr/local/mysql/bin/mysql -u root

  UPDATE mysql.user SET authentication_string=PASSWORD('your new password') WHERE User='root';

  FLUSH PRIVILEGES;

  exit

4. Restart MySQL.

Okay, that's it.

Knowledge points supplement

Windows:

1. Log in to the system as a system administrator.

2. Open cmd-----net start to check whether mysql is started. If started, stop it with net stop mysql.

3. My mysql is installed in d:\usr\local\mysql4\bin.

4. Skip the permission check and start mysql.

d:\usr\local\mysql\bin\mysqld-nt --skip-grant-tables

5. Reopen cmd. Go to d:\usr\local\mysql4\bin:

d:\usr\local\mysql\bin\mysqladmin -u root flush-privileges password "newpassword"

d:\usr\local\mysql\bin\mysqladmin -u root -p shutdown This sentence prompts you to re-enter the password.

6. In cmd, net start mysql

7. Done.

Linux:

One of the methods to recover MySQL root password

If you forget the MySQL root password, you can reset it using the following method:

1.KILL the MySQL process in the system;

killall -TERM MySQLd

2. Start MySQL with the following command without checking permissions;
safe_MySQLd --skip-grant-tables &

3. Then log in to MySQL as root user with an empty password;

MySQL -u root

4. Change the root user's password;

MySQL> update MySQL.user set password=PASSWORD('new password') where User='root'; 
MySQL> flush privileges; 
MySQL> quit

Restart MySQL and you can log in using the new password.

This is the end of this article about the easiest way to reset the mysql root password. For more information about how to reset the mysql root password under mysql, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • What should I do if I forget my MySQL password? How to reset MySQL root password
  • Detailed method for forgetting the root password or resetting the password in Mysql 5.7
  • How to reset the root password in mysql8.0.12
  • How to reset MySQL root password under Windows
  • Reset mysql root password in linux system
  • How to reset the root user password of MySQL database if you forget it [Graphic]
  • How to reset the root password of Mysql in Windows if you forget it
  • Complete steps to reset the root user password in mysql8
  • How to solve the problem "Unknown column 'password" when resetting MySQL root password
  • A practical record of MySql resetting the root password and failing

<<:  Example of how to build a Harbor public repository with Docker

>>:  Detailed explanation of Nginx status monitoring and log analysis

Recommend

Front-end vue+express file upload and download example

Create a new server.js yarn init -y yarn add expr...

Are the value ranges of int(3) and int(10) the same in mysql

Table of contents Question: answer: Reality: Know...

Detailed explanation of javascript knowledge points

Table of contents 1. Basic Introduction to JavaSc...

Detailed explanation of deploying MySQL using Docker (data persistence)

This article briefly describes how to use Docker ...

CSS3 achieves flippable hover effect

CSS3 implements a flippable hover effect. The spe...

Use Docker to create a distributed lnmp image

Table of contents 1. Docker distributed lnmp imag...

Let's talk about bitwise operations in React source code in detail

Table of contents Preface Several common bit oper...

Understanding and application scenarios of enumeration types in TypeScript

Table of contents 1. What is 2. Use Numeric Enume...

Several methods to clear floating (recommended)

1. Add an empty element of the same type, and the...

MySQL 1130 exception, unable to log in remotely solution

Table of contents question: 1. Enable remote logi...

Detailed explanation of the usage and difference between nohup and & in Linux

Example: We use the Python code loop_hello.py as ...

Complete steps to implement location punch-in using MySQL spatial functions

Preface The project requirement is to determine w...

Angular environment construction and simple experience summary

Introduction to Angular Angular is an open source...

Docker's four network types principle examples

Four network types: None: Do not configure any ne...