What to do if you forget the root password of Mysql5.7 (simple and effective method)

What to do if you forget the root password of Mysql5.7 (simple and effective method)

In the previous article, we introduced how to forget the root password in MySQL 5.7 and how to modify the root password in MySQL 5.7

A quick and simple solution to forget the password of Mysql5.7. The specific method details are as follows:

# The simplest and most brutal way is to find the mysql configuration file and edit it directly with vim /etc/my.cnf
 # Add a line in [mysqld] to skip the permission restriction skip-grant-tables
# Save and exit to restart the mysql service service mysqld restart
# User login mysql -uroot -p (click Enter directly, the password is empty)
# Select database use mysql;
# But the password field does not exist in version 5.7, so we need to use the following modification to reset the password update user set authentication_string=password('new password') where user='root';
#Flush privileges;
# Exit mysql
quit;
# Delete skip-grant-tables in the configuration file my.cnf that was modified at the beginning and restart mysql
service mysqld restart
# After you log in to MySQL, you will find that when you execute the command, ERROR 1820 (HY000) will appear: You must reset your password using ALTER USER statement;
# This is a reminder that you need to change the password when you execute SET PASSWORD = PASSWORD('root');
# If ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
# You need to execute two parameters to cancel the default password strength of MySQL. Of course, you can also increase the complexity of your password. set global validate_password_policy=0; 
set global validate_password_mixed_case_count=2;
# Now you can execute it again and it will be ok SET PASSWORD = PASSWORD('root');
# Let's talk about the character set problem in MySQL show variables like "%character%";
# The following situations can be ignored...
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
#Find the mysql configuration file and add a few words to it. Add character-set-server=utf8 under mysqld
collation-server=utf8_general_ci
# Add default-character-set=utf8 under client

The above is what I introduced to you about what to do if you forget the root password of Mysql5.7 (a simple and effective method). 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. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Solution for forgetting the root password of MySQL5.7 under Windows 8.1
  • Detailed tutorial on how to modify the root password after forgetting it in MySQL 5.7
  • How to change the root password of Mysql5.7.10 on MAC
  • Solution to forgetting the root password of MySQL5.7 on Mac
  • MySQL 5.7 installation process and method to reset the root password (shell script)
  • Detailed method for forgetting the root password or resetting the password in Mysql 5.7
  • Problem of retrieving root password in MYSQL 5.7 under Linux (tested and available)

<<:  How to reset the root password in CentOS7

>>:  JS implements simple calendar effect

Recommend

How to solve the timeout during pip operation in Linux

How to solve the timeout problem when pip is used...

Detailed installation tutorial for MySQL zip archive version (5.7.19)

1. Download the zip archive version from the offi...

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

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

HTML+jQuery to implement a simple login page

Table of contents Introduction Public code (backe...

Detailed explanation of Truncate usage in MYSQL

This article guide: There are two ways to delete ...

Next.js Getting Started Tutorial

Table of contents Introduction Create a Next.js p...

How to configure MySQL scheduled tasks (EVENT events) in detail

Table of contents 1. What is an event? 2. Enable ...

Virtual Box tutorial diagram of duplicating virtual machines

After getting used to VM, switching to BOX is a l...

JavaScript simulation calculator

This article shares the specific code of JavaScri...

Several ways to submit HTML forms_PowerNode Java Academy

Method 1: Submit via the submit button <!DOCTY...

Detailed explanation of html-webpack-plugin usage

Recently, I used html-webapck-plugin plug-in for ...