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 5.7.17 installation and configuration tutorial under CentOS6.9

CentOS6.9 installs Mysql5.7 for your reference, t...

Detailed explanation of Docker Swarm concepts and usage

Docker Swarm is a container cluster management se...

About debugging CSS cross-browser style bugs

The first thing to do is to pick a good browser. ...

Difference between HTML ReadOnly and Enabled

The TextBox with the ReadOnly attribute will be di...

What is a MySQL index? Ask if you don't understand

Table of contents Overview From Binary Tree to B+...

Linux kernel device driver character device driver notes

/******************** * Character device driver**...

Detailed explanation of angular two-way binding

Table of contents Bidirectional binding principle...

JS implements Baidu search box

This article example shares the specific code of ...

MySQL database query performance optimization strategy

Optimize queries Use the Explain statement to ana...

Detailed explanation of how to enable slow query log in MySQL database

The database enables slow query logs Modify the c...

A MySQL migration plan and practical record of pitfalls

Table of contents background Solution 1: Back up ...

Briefly describe the use and description of MySQL primary key and foreign key

Table of contents 1. Foreign key constraints What...

How to enable MySQL remote connection

For security reasons, MySql-Server only allows th...