Solve the problem of forgetting password in MySQL 5.7 under Linux

Solve the problem of forgetting password in MySQL 5.7 under Linux

1. Problem

Forgot password for mysql5.7 under linux

2. Solution

• Step 1: Open the mysql5.7 configuration file my.cnf and add a line to it: skip-grant-tables Save and exit (:wq)

[root@iz09a32x1sghz3z ~]# vi /etc/my.cnf

• Step 2: Restart mysql

[root@iz09a32x1sghz3z ~]# service mysqld restart

•Step 3: Log in to mysql and change the password

Log in with the root account: [root@iz09a32x1sghz3z ~]# mysql -u root

Use the mysql database in mysql: mysql> use mysql;

Change password: update user set authentication_string = password("Szfore_68638") where user="root" ;

Refresh the database: flush privileges;

Exit: quit;

Note: The password field in the user table of MySQL 5.7 has been changed to the authentication_string field.

At this time, the command you need to enter is update user set authentication_string = password("Szfore_68638") where user="root";

• Step 4: Open the mysql5.7 configuration file my.cnf, delete the line you just added: skip-grant-tables, save and exit (:wq)
•Step 5: Restart MySQL and log in with the modified password.

[root@iz09a32x1sghz3z ~]# service mysqld restart

Summarize

The above is what I introduced to you about how to solve the problem of forgetting the password of Mysql5.7 under Linux. 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!

You may also be interested in:
  • Linux MySQL root password forgotten solution
  • How to modify the root user password in mysql 8.0.16 winx64 and Linux
  • MySQL 8.0.15 installation and configuration graphic tutorial and password change under Linux
  • Solution to forgetting mysql password under linux
  • Several ways to recover forgotten MySQL password under Linux (recommended)
  • Install MySQL database 5.6 source code under Linux and change the login user password
  • A simple way to change the password of mysql just installed in Linux
  • How to reset MySQL root password in Linux (CentOS)
  • How to reset the root password in Linux mysql-5.6

<<:  Basic implementation method of cross-component binding using v-model in Vue

>>:  mysql database to retrieve the statements of seconds, minutes, hours and days before and after

Recommend

A detailed introduction to the basics of Linux scripting

Table of contents 1. Script vim environment 2. Ho...

The difference between html Frame, Iframe and Frameset

10.4.1 The difference between Frameset and Frame ...

Sample code for JS album image shaking and enlarging display effect

The previous article introduced how to achieve a ...

Summary of four ways to loop through an array in JS

This article compares and summarizes four ways of...

Summary of commonly used multi-table modification statements in Mysql and Oracle

I saw this question in the SQL training question ...

How to specify parameter variables externally in docker

This article mainly introduces how to specify par...

Solution to MySQL IFNULL judgment problem

Problem: The null type data returned by mybatis d...

MySQL 5.6.37 (zip) download installation configuration graphic tutorial

This article shares the download, installation an...

Vue implements a scroll bar style

At first, I wanted to modify the browser scroll b...

Shtml Concise Tutorial

Shtml and asp are similar. In files named shtml, s...

Linux kernel device driver kernel time management notes

/****************** * Linux kernel time managemen...

jQuery implements nested tab function

This article example shares the specific code of ...

Implementing carousel effects with JavaScript

This article shares the specific code for JavaScr...

Details of the underlying data structure of MySQL indexes

Table of contents 1. Index Type 1. B+ Tree 2. Wha...