MySQL5.7 Change the default password, random password

Source: Internet
Author: User

mysql5.7 generate random password after default, modify root user password

  1. Modify Configuration parameters
Linux:/etc/my.cnf
Windows:c:\programdata\mysql\mysql Server 5.7\my.ini
Add a line under the [mysqld] section:Skip-grant-tables=1 This line of configuration lets mysqld not validate the password when it starts
Or add a command when you start the service: Service mysqld start--skip-grant-tables

 2. Restart MySQL Service
Linux:service mysqld Restart
Windows:net Start/stop MySQL57

  3. Log in to MySQL using the root user:
Linux:mysql-u Root
Windows: You must start cmd with administrator privileges, switch to C:\Program files\mysql\mysql Server 5.7\bin,mysql-u root-p

  4, switch to the MySQL database, update the user table, the user table has all the information saved
Update user set Password=password (' root ') where user= "New_password";
Alter user ' root ' @ ' localhost ' identified by ' new_password ';
Update user Set authentication_string = password (' new_password '), password_expired = ' n ', password_last_changed = Now () WH ere user = ' root ';

Note: In previous versions, the field name of the password field was password,5.7 to authentication_string

  5. Exit MySQL, edit the/etc/my.cnf or C:\ProgramData\MySQL\MySQL Server 5.7\my.ini file, delete the Skip-grant-tables=1 line
MySQL three exit commands: Exit; Quit; \q;

  6, restart the Mysqld service, and then login with the new password can

Note: MySQL 5.7 generates a random initial password after initial installation (Centos7 OS), and is recorded in the/var/log/mysqld.log, can be viewed through the cat command, find the password keyword found password

MySQL5.7 Change the default password, random password

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.