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

LINUX Checks whether the port is occupied

I have never been able to figure out whether the ...

A very detailed explanation of the Linux DHCP service

Table of contents 1. DHCP Service (Dynamic Host C...

A brief discussion of several browser compatibility issues encountered

background Solving browser compatibility issues i...

Detailed explanation of the difference between docker-compose ports and expose

There are two ways to expose container ports in d...

How to fix the width of table in ie8 and chrome

When the above settings are used in IE8 and Chrome...

Analysis of the difference between bold <b> and <strong>

All of us webmasters know that when optimizing a ...

Implementation of vue-nuxt login authentication

Table of contents introduce Link start Continue t...

HTML table tag tutorial (13): internal border style attributes RULES

RULES can be used to control the style of the int...

Summary of CSS3 practical methods (recommended)

1. Rounded border: CSS CodeCopy content to clipbo...

JavaScript prototype and prototype chain details

Table of contents 1. prototype (explicit prototyp...

my.cnf parameter configuration to optimize InnoDB engine performance

I have read countless my.cnf configurations on th...

How to view the docker run startup parameter command (recommended)

Use runlike to view the docker run startup parame...