MySQL 5.7 above root user default password problem "Go"

Source: Internet
Author: User

Https://www.yanning.wang/archives/379.html

Nonsense less say a Word series:

CentOS system use Yum to install MySQL friends, use the grep "temporary password"/var/log/mysqld.log command, return the result the string following the last quotation mark is the default password for root.

A little bit of a problem recently, you need to build a MySQL server in the local virtual machine. But by following the previous log, it will always be stuck in the root login after MySQL was installed.

After you've installed MySQL, you can use it directly

Mysql-uroot

Entered the MySQL console, the result is now not, will prompt

ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)

was denied access. At first I thought it was because I had previously set the mariadb password for CentOS, and MySQL replaced mariadb when I installed MySQL, but inherited the mariadb password and then used the command:

Mysql-uroot-p

To bring a password to login, but tried a few passwords are wrong.

Happened later because of the hands of the cheap committed something, the system was I play fried, re-installed the CentOS system. When you install MySQL again, there is no way to log into the console, the same hints as before.

That's a little tricky, isn't it? MySQL now has a default password? Holding this suspicion to the MySQL official website to look up documents, really!

In the MySQL article entitled "Changes in MySQL 5.7.4 (2014-03-31, Milestone 14)", there is a paragraph:

Incompatible Change:mysql deployments installed using mysql_install_db now is secure by default. The following changes has been implemented as the default deployment characteristics:

The installation process creates only a single root account, ' root ' @ ' localhost ', automatically generates a random password For this account, and marks the password expired. The MySQL administrator must connect as root using the random password and use SET password to select a new password. (The random password is found in the. mysql_secret file in the home directory of the effective user running the script.)

Installation creates no Anonymous-user accounts.

Installation creates no test database.

Personal slag-flipping is as follows:

Incompatible changes: MySQL deployment installation uses mysql_install_db, which is now safe by default. The following changes have been implemented and become the default deployment feature:

During the installation process, only one root account will be created-' root ' @ ' localhost ' and will automatically generate a random password to it and flag that the password has expired. the MySQL administrator must log in to the root account with a random password and use set PASSWORD to set a new password . (a random password can be found in the . Mysql_secret file in the home directory of a valid user who runs the installation script .) )

Anonymous user accounts are not created at installation time.

The test database is not created at installation time.

I already have the red bold font highlighted. But this is a script deployment, I was directly add the MySQL source into the system source, and then installed with the yum install mysql-community-server command, so naturally there is no way to find in the main directory ". Mysql_ Secret "file. Where is the code?

In fact, MySQL in the run time will have a log file, it exists in/var/log/mysqld.log, we install the random password generated in this file, we can directly use the following command to display all the contents of this file:

Cat/var/log/mysqld.log

This screen full of words, look at the faint, if I say the password is already in the above, you can immediately find it? It must take a long time, so we can use a more convenient command here:

grep "Temporary password"/var/log/mysqld.log

How about, now the password is not very clear? is set to "M6qvln8kyq?d".

You can now log in to the MySQL console with a random password.

Now finally into the console, the next thing to do is to change the password, after all, so a bunch of passwords who can not remember it? The command to set a new password is:

SET PASSWORD = PASSWORD (' Your new password ');

However, it is important to note that MySQL is now forced to require strong passwords, can no longer use weak passwords such as "123456". If you set the password too simple, you will be prompted with an error:

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

Written in the end: This problem is still very tricky, because completely do not know MySQL later added the initial random password problem, asked a few friends they said their deployment without this problem, finally had to find official documents. One is the document all in English, the second is their own English slag, plus the related documents released earlier, and finally spent a lot of time on this. Anyway, I don't know what to say to MySQL ...

Root User default password Problem "Go" above MySQL 5.7

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.