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

HTML line spacing setting methods and problems

To set the line spacing of <p></p>, us...

Nginx rush purchase current limiting configuration implementation analysis

Due to business needs, there are often rush purch...

JS implements city list effect based on VUE component

This article example shares the specific code for...

Summary of some points to note when registering Tomcat as a service

Here are some points to note when registering Tom...

Detailed explanation of samba folder sharing server configuration under centos

1. Introduction Recently I found that there are m...

A brief discussion of 12 classic problems in Angular

Table of contents 1. Please explain what are the ...

Various types of MySQL indexes

What is an index? An index is a data structure th...

Detailed explanation of this pointing problem in JavaScript function

this keyword Which object calls the function, and...

Summary of some related operations of Linux scheduled tasks

I have searched various major websites and tested...

How to design MySQL statistical data tables

Table of contents Is real-time update required? M...

mysql 5.7.11 winx64.zip installation and configuration method graphic tutorial

Install and configure the MySql database system. ...

Detailed explanation of MySQL backup process using Xtrabackup

Table of contents 01 Background 02 Introduction 0...