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

MySQL uses covering index to avoid table return and optimize query

Preface Before talking about covering index, we m...

Design theory: people-oriented green design

Reflections on the two viewpoints of “people-orie...

How to let DOSBox automatically execute commands after startup

Using DOSBox, you can simulate DOS under Windows ...

Differences and comparisons of storage engines in MySQL

MyISAM storage engine MyISAM is based on the ISAM...

How to remove the dividing line of a web page table

<br />How to remove the dividing lines of a ...

Vue+el-table realizes merging cells

This article example shares the specific code of ...

Based on the special characters in the URL escape encoding

Table of contents Special characters in URLs URL ...

How to implement Mysql scheduled task backup data under Linux

Preface Backup is the basis of disaster recovery....

Does MySql need to commit?

Whether MySQL needs to commit when performing ope...

Problems and experiences encountered in web development

<br />The following are the problems I encou...

Docker port mapping and external inaccessibility issues

The Docker container provides services and listen...