Solution to the root password login problem in MySQL 5.7

Solution to the root password login problem in MySQL 5.7

After I found that the previous article solved the problem of MySQL service failing to start, I found that I could not log in with the root user without a password. The 5.7 version could not log in with the root user without a password during initialization. After searching many posts, I solved the problem.

It turns out that in the .err file in the data file generated by the mysqld –initialize method in the previous article, you can open it with word and there will be a temporary initial password for generating root

這里寫圖片描述

After opening, find the password:

這里寫圖片描述

However, this password will expire and cannot be used after being used once. Now let's change this password

1. First shut down the mysql service, net stop mysql

2. Modify your MySQL configuration file my.ini or my-default.int. See which file to modify according to your own configuration.

3. Add skip-grant-tables to the [mysqld] node
The main function is to skip the verification in the table and log in without a password.

4. Start the MySQL service (net start mysql), and use a visual client to enter MySQL. I use the visual client mysqlFront, you can find it on Baidu.

5. Open the user table under MySQL and change the Y in the password_expired field to N. This is mainly to change whether the password is valid. There are two types, Y/N. Y means expired, and n means valid. Remember to save after changing it.

6. Stop the mysql service, delete the skip-grant-tables in the ini file, and restart the service

7. Change password: mysqladmin -u root password root

Enter the original password and the change is successful. The last root is the new password

這里寫圖片描述

The password has been changed successfully and you can log in, mysql -uroot -p

Enter the password root you just set to log in

這里寫圖片描述

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:
  • A quick solution to the first login failure in mysql5.7.20
  • How to install the green version of MySQL Community Server 5.7.16 and implement remote login
  • Solve the problem of ERROR 1045 (28000): Access denied for user ''root''@''localhost'' when logging in after installing MySQL 5.7.17 on Ubuntu 16.04
  • Tutorial on logging into MySQL after installing Mysql 5.7.17
  • Solve the problem of being unable to log in after installing MySQL 5.7 without a data folder
  • Solution to the problem of Access denied for user'root'@'localhost' (using password: YES) in MySQL 8.0 login under win10

<<:  Detailed explanation of installing applications in Linux Centos7 without Internet connection

>>:  How to use the Clipboard API in JS

Recommend

MySQL uses the truncate command to quickly clear all tables in a database

1. Execute the select statement first to generate...

Vue implements interface sliding effect

This article example shares the specific code of ...

Professional and non-professional web design

First of all, the formation of web page style main...

Apache Bench stress testing tool implementation principle and usage analysis

1: Throughput (Requests per second) A quantitativ...

Vue3 implements CSS infinite seamless scrolling effect

This article example shares the specific code of ...

JavaScript implements checkbox selection function

This article example shares the specific code of ...

MySQL InnoDB monitoring (system layer, database layer)

MySQL InnoDB monitoring (system layer, database l...

Simple steps to configure Nginx reverse proxy with SSL

Preface A reverse proxy is a server that receives...

Graphic tutorial on installing tomcat8 on centos7.X Linux system

1. Create the tomcat installation path mkdir /usr...

Summary of various implementation methods of mysql database backup

This article describes various ways to implement ...

Detailed explanation of MYSQL log and backup and restore issues

This article shares MYSQL logs and backup and res...

Detailed analysis of when tomcat writes back the response datagram

The question arises This question arose when I wa...