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

Easyswoole one-click installation script and pagoda installation error

Frequently asked questions When you are new to ea...

Css3 realizes seamless scrolling and anti-shake

question The seamless scrolling of pictures and t...

Details of various font formats in HTML web pages

This section starts with the details of text modi...

The solution of html2canvas that pictures cannot be captured normally

question First, let me talk about the problem I e...

Introduction to ApplicationHost.config (IIS storage configuration area file)

For a newly created website, take ASP.NET MVC5 as...

Overview and Introduction to Linux Operating System

Table of contents 1. What is an Operating System ...

Vue+element+oss realizes front-end fragment upload and breakpoint resume

Pure front-end implementation:切片上傳斷點續傳.斷點續傳needs ...

JavaScript's unreliable undefined

undefined In JavaScript, if we want to determine ...

Linux general java program startup script code example

Although the frequency of starting the shell is v...

Docker commands are implemented so that ordinary users can execute them

After installing docker, there will usually be a ...

Example of how to create a local user in mysql and grant database permissions

Preface When you install MySQL, you usually creat...

MySQL 5.7.18 download and installation process detailed instructions

MySql Download 1. Open the official website and f...

How to insert video into HTML and make it compatible with all browsers

There are two most commonly used methods to insert...

How to use Portainer to build a visual interface for Docker

Portainer Introduction Portainer is a graphical m...

How to package the uniapp project as a desktop application

Installing Electron cnpm install electron -g Inst...