Linux under the root login MySQL error problem _mysql

Source: Internet
Author: User

Recently in CentOS 7, through the Yum installed MySQL, after the successful installation, using root login, there are the following error:

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

MySQL version: Ver 14.14 distrib 5.7.10, for Linux (x86_64) using Editline Wrapper

However, the root password setting has not actually been set (do not know if the installation process has been overlooked?) )。

To find answers to this, there are roughly the following:

There is a random password that says root is located in/root/.mysql_secret, but I have no/root/.mysql_secret file at all. An article said

> ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using
> Password:no): Temporary password that does not generate root
> 
> ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using
> Password:yes): Indicates that a temporary password was generated for root.

Some information that the default password root is empty, confirmed that the previous version, Mysql 5.6 and later version out of security considerations, the root password is not empty.
Finally find a solution that is useful to me.

Causes:

Now that's password MySQL had generated is expired, the problem was reduced to getting this password to work again (1) or Generate a new one (2). This can is accomplished by running MySQL and the skip-grant-tables option which would make it ignore the access rights:

Workaround:

Copy Code code as follows:

Stop your MySQL server.
Add skip-grant-tables at the [mysqld] section of my.cnf file and save it.
Start MySQL Server.
In terminal, the Typemysql-u Root-pto get into the MySQL command prompt.
In the command prompt, Typeuse mysql;to get into the MySQL database where it keeps database users.
Type
UPDATE user SET password_expired = ' N ' WHERE user = ' root ';
To let MySQL know the password isn't expired (1) or
UPDATE user SET authentication_string = PASSWORD (' Yournewpassword '), password_expired = ' N ' WHERE user = ' root ';

Attached Links: Unable to access MySQL after it automatically generated a temporary password

Released for your reference.

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.