Linux/Mac MySQL forgotten password command line method to change the password

Linux/Mac MySQL forgotten password command line method to change the password

All prerequisites require root permissions

1. End the mysql process

//Linux
sudo services mysql stop
//Mac
brew services stop mysql

2.mysql background running

mysqld_safe --skip-grant-tables &
mysql

&, means running in the background without opening a new terminal

3. Change password

use mysql;
update user set password = password("new password") where user='root';
flush privileges;

Knowing the original password

Use the mysqladmin command on the command line

mysqladmin -u root -p oldpassword "newpassword"

Or you can enter the MySQL database and modify it directly, refer to the third step above [Change Password]

The above is the method of changing the password of Linux/Mac MySQL command line when you forget the password. 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:
  • Two ways to change passwords in Linux through Shell script commands
  • A simple way to change the password of mysql just installed in Linux
  • Python implements batch password modification on Linux servers and generates execl
  • Common Linux commands for beginners: password - change password, change user
  • Detailed example of changing Linux account password

<<:  Detailed explanation of docker command to backup linux system

>>:  How to use Dayjs to calculate common dates in Vue

Recommend

HTML image img tag_Powernode Java Academy

summary Project description format <img src=&q...

Detailed explanation of vue simple notepad development

This article example shares the specific code of ...

In-depth understanding of Vue's method of generating QR codes using vue-qr

Table of contents npm download step (1) Import (2...

Comparison of the use of form element attributes readonly and disabled

1) Scope of application: readonly:input[type="...

Responsive layout summary (recommended)

Basic knowledge of responsive layout development ...

How to use CSS to display multiple images horizontally in the center

Let me first talk about the implementation steps:...

JavaScript Canvas implements Tic-Tac-Toe game

This article shares the specific code of JavaScri...

Tutorial on installing Apache 2.4.41 on Windows 10

1. Apache 2.4.41 installation and configuration T...

Teach you how to monitor Tomcat's JVM memory through JConsoler

Table of contents 1. How to monitor Tomcat 2. Jav...

JS implements jQuery's append function

Table of contents Show Me The Code Test the effec...

js to achieve image fade-in and fade-out effect

This article shares the specific code of js to ac...

Pure CSS to achieve cool neon light effect (with demo)

I have recently been following the CSS Animation ...