Solution to forgetting mysql password under linux

Solution to forgetting mysql password under linux

The problem is as follows: I entered the command mysql -uroot -p, but I forgot the password.

Step 1: Stop the mysql service

There are methods on the Internet to open /etc/my.cnf and modify it, but I didn't find the file in this directory at all. Maybe it’s due to the version!

Enter the command to stop the mysql service: /etc/init.d/mysql stop

Step 2: Start mysql safely and skip the authorization table: mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

Step 3: Reset MySQL password

Input: mysql -uroot -p. You don’t need to enter a password at this time. Just press Enter to enter.

Enter the statement: use mysql, that is, select a database, enter the statement to reset the password, and I found the following problem, which means that the password column is not included

So the authentication_string column should be modified

Then enter the command: flush privileges to refresh the MySQL system privilege related tables. quit Exit mysql

Step 4: Restart the service and enter the newly set password to log in

Restart the mysql service: /etc/init.d/mysql restart

Enter the password and enter mysql.

For more information, please see the topic: MySQL password operation summary

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:
  • How to solve the problem of forgetting MySQL password
  • How to modify mysql user password and how to solve mysql password forgetting
  • Detailed explanation of the solution to forget the root password of mysql in windows environment
  • Solution to forgetting the root password of mysql under windows
  • Solution to forgetting mysql password
  • Mysql forgotten password solution

<<:  js to achieve simple calendar effect

>>:  Implementation of Nginx domain name forwarding

Recommend

Detailed explanation of using pt-heartbeat to monitor MySQL replication delay

pt-heartbeat When the database is replicated betw...

Detailed tutorial on running selenium+chromedriver on the server

1. Introduction I want to use selenium to scrape ...

How to force vertical screen on mobile pages

I recently wrote a mobile page at work, which was...

Using HTML web page examples to explain the meaning of the head area code

Use examples to familiarize yourself with the mean...

Pure CSS to change the color of the picture

The css technique for changing the color of an im...

How to import Excel files into MySQL database

This article shares with you how to import Excel ...

Detailed explanation of the mysql database LIKE operator in python

The LIKE operator is used in the WHERE clause to ...

Tutorial on how to remotely connect to MySQL database under Linux system

Preface I recently encountered this requirement a...

Why web page encoding uses utf-8 instead of gbk or gb2312?

If you have a choice, you should use UTF-8 In fac...

K3s Getting Started Guide - Detailed Tutorial on Running K3s in Docker

What is k3d? k3d is a small program for running a...

How to configure Nginx domain name rewriting and wildcard domain name resolution

This article introduces how to configure Nginx to...

Vue routing to implement login interception

Table of contents 1. Overview 2. Routing Navigati...

Implementation example of scan code payment in vue project (with demo)

Table of contents Demand background Thought Analy...

Example code for achieving hollowing effect with pure CSS

I have recently studied the hollowing effect. bac...