ERROR 1045 (28000): Access denied for user ' roort '

Source: Internet
Author: User

Problem phenomenon:

Error message:

ERROR 1044 (42000): Access denied for user "@ ' localhost ' to database ' MySQL ' or

ERROR 1045 (28000): Access denied for user ' roort ' @ ' localhost ' (using Password:yes)

Cause of failure:

The user table in the MySQL database has an account with an empty username, which is an anonymous user. Causes the log in the time although uses the root, but actually is the anonymous login, through the error prompt ' @ ' localhost ', can see.

Workaround:

1. Stop mysqld service

[[Email protected] ~]# service mysqld stop

2 , in the configuration file /etc/my.cnf Add Skip-grant-tables One line, skip password verification

[Email protected] ~]# VIM/ETC/MY.CNF

[Mysqld]

Datadir=/data/mysql

User=mysql

Log-bin=mysql-bin

Basedir=/usr/local/mysql

skip-grant-tables// Add Skip-grant-tables

3, start the Mysqld service, in the new open terminal input

[[email protected] ~]# MySQL

mysql> use MySQL;

Mysql> Select User from user;

+------+

| user |

+------+

| Root |

| Root |

| Root |

| |

| |

| Root |

6 rows in Set (0.00 sec)

you can see that there are 2 anonymous accounts with a blank user name.

mysql> Delete from user where user= ';

Query OK, 2 rows Affected (0.00 sec)

mysql> flush Privileges;

Query OK, 0 rows Affected (0.00 sec)

4, in the configuration file /etc/my.cnf Delete skip-grant-tables



ERROR 1045 (28000): Access denied for user ' roort '

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.