mysql5.7 series Change root default password

Source: Internet
Author: User

Operating system is CENTOS7 64

1, modify the/ETC/MY.CNF, add a line under the [mysqld] subsection: Skip-grant-tables=1

This line of configuration allows mysqld to be not validated at startup

2. Restart MYSQLD service: systemctl restart Mysqld

3. Log in to Mysql:mysql-u root using the root user

4. Switch to MySQL database and update user table:

Update user Set authentication_string = password (' root '), password_expired = ' N ', password_last_changed = Now () where user = ' root ';

In previous versions, the field name for the password field was password,5.7 to authentication_string

5. Quit MySQL, edit the/etc/my.cnf file, delete the contents of Skip-grant-tables=1

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

In addition, MySQL 5.7 generates a random initial password after initial installation (CentOS7 OS) and is recorded in the/var/log/mysqld.log, which can be viewed through the cat command, looking for the password keyword

After locating the password, log in with the initial password, and (only) change the root user's password to root by alter user ' root ' @ ' localhost ' identified by ' root ', then exit, Log in again with the root user and the password you just set.

mysql5.7 series Change root default 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.