What to do if you forget your Linux/Mac MySQL password

What to do if you forget your Linux/Mac MySQL password

What to do if you forget your Linux/Mac MySQL password? Don't worry, here's how to change your password using the command line.

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 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:
  • Multiple solutions for linux mysql forgotten password or Access denied for user ''root''@''localhost''
  • How to solve the mysql password forgetting (linux and windows summary)
  • Linux/Mac MySQL forgotten password command line method to change the password
  • What to do if you forget your mysql password (windows linux)
  • Linux system MySQL forgotten password, reset password, ignore the case of table and column names
  • How to modify the forgotten password when installing MySQL on Mac
  • Solution to forget password when installing MySQL on Linux/Mac

<<:  Native js to implement 2048 game

>>:  Realization of real-time file synchronization between Linux servers

Recommend

Pure CSS to achieve hover image pop-out pop-up effect example code

Implementation principle The main graphics are co...

MySQL scheduled task example tutorial

Preface Since MySQL 5.1.6, a very unique feature ...

Vue implements the question answering function

1. Request answer interface 2. Determine whether ...

How does the composite index of MySQL take effect?

Table of contents background Understanding compos...

JavaScript ES new feature block scope

Table of contents 1. What is block scope? 2. Why ...

Detailed explanation of Django+Vue+Docker to build an interface testing platform

1. Two words at the beginning Hello everyone, my ...

Detailed explanation of HTML style tags and related CSS references

HTML style tag style tag - Use this tag when decl...

Talk about how to identify HTML escape characters through code

Occasionally you'll see characters such as &#...

The HTML 5 draft did not become a formal standard

<br />Yesterday I saw at W3C that the new HT...

Perfect solution to the problem of webpack packaging css background image path

Inside the style tag of the vue component, there ...

Box-shadow and drop-shadow to achieve irregular projection example code

When we want to add a shadow to a rectangle or ot...

Linux kernel device driver address mapping notes

#include <asm/io.h> #define ioremap(cookie,...

Detailed explanation of mandatory and implicit conversion of types in JavaScript

Table of contents 1. Implicit conversion Conversi...