Mysql5.7 What should I do if I forget the root password (simple and effective), mysql5.7root

Source: Internet
Author: User

Mysql5.7 What should I do if I forget the root password (simple and effective), mysql5.7root

In the previous article, I introduced Mysql5.7 how to forget the root password and mysql5.7 how to change the root password.

Mysql5.7 is a quick and simple solution for forgetting a password. The detailed method is as follows:

# The simplest and most crude method is to find the mysql configuration file and directly edit vim/etc/my. cnf # Add the last line in [mysqld] to skip the permission restriction skip-grant-tables # Save and quit and restart mysql service mysqld restart # log on to mysql-uroot-p (directly press enter, password is blank) # select the database use mysql; # But the password field does not exist in version 5.7. use the following changes to reset the password: update user set authentication_string = password ('new password ') where user = 'root'; # refresh permission flush privileges; # exit mysqlquit; # change the configuration file my. delete and restart mysqlservice mysqld re from skip-grant-tables in cnf Start # After You log on to mysql, You will find that when You execute the command, ERROR 1820 (HY000): You must reset your password using alter user statement will appear; # This is a prompt that you need to change the PASSWORD when you execute set password = PASSWORD ('root'); # If ERROR 1819 (HY000) appears ): 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; # Then you can execute it again. SE T password = PASSWORD ('root'); # show variables like "% character %" about character sets in mysql; # ignore the following situations ............ + Bytes + | Variable_name | Value | + bytes + | character_set_client | utf8 | character_set_connection | utf8 | character_set_database | utf8 | bytes | binary | utf8 | | character_set_server | utf8 | character_set_system | utf8 | character_sets_dir |/usr/share/mysql/charsets/| + keys + # add a few words to the mysql configuration file. add character-set-server = utf8collation-server = utf8_general_ci under mysqld # Add default-character-set = utf8 under client

The above section describes how to forget the root password of Mysql5.7 (simple and effective). I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.