Problems with initial root password not found after initial installation of Mysql5.7 or above version

Source: Internet
Author: User

One of the main aspects of mysql5.7 's new features is a great increase in security, which, by default, creates a random password for the [email protected] user after installing MySQL, a random password that needs to be found in different ways on different systems. Otherwise, you cannot log in to MySQL and modify the initial password.

The following is a CentOS 7 example of how to find the initial random password.

On a version less than MySQL 5.7.6, MySQL initializes the database with the mysql_install_db command, which creates a. mysql_secret file in the root directory of the user who installed MySQL, which records the random password generated by the initialization. Users can log in to MySQL with a password and re-modify the password.


For the later 5.7 series versions of MySQL 5.7.6, MySQL initializes the database with the mysqld--initialize or mysqld--initialize-insecure command, which can not generate random passwords. However, when installing MySQL, the default is to use the previous command, which also generates a random password. The password is saved in the MySQL log file.

After installing MySQL using the rpm command on the CentOS 7 system, the MySQL configuration file is/etc/my.cnf, open the file, you can see the configuration information of MySQL DataDir and log files, and the following:

Datadir=/var/lib/mysql

Log-error=/var/log/mysqld.log


Open the/var/log/mysqld.log file, search string a temporary password is generated for [email protected]:, you can find this random password, usually this line of logs in the first few lines of the log file, more easily seen.

Log in to MySQL with the random password you found, and after the first login, MySQL will not be able to perform any other database operations than it has to modify the default password, which reflects the ever-increasing MySQL security.


Problems with initial root password not found after initial installation of Mysql5.7 or above version

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.