MySQL new user cannot log on locally

Source: Internet
Author: User

MySQL new user cannot log on locally mysqldebiangoogleaccess this is with MySQL because the root privilege is too high, so create a new user appadmin, only the database to be used. The creation statement is as follows: Grant Select,insert,update,delete on test.* to [email protected] "%" identified by "password", where @ "%" is available at any address.
After creation to mysql.user under view, there is the user. However, using Mysql-u Appadmin-ppassword login, prompt cannot log in: ERROR 1045 (28000): Access denied for user ' appadmin ' @ ' localhost ' (using PASSWO Rd:yes)
Best of all, Google, one of them said, "There are other records in the Mysql.user table has a role, most likely, there is already a" @localhost record, that is, the user name is empty, the host field is localhost record. "Affected. Look at the table and it sure is.
Mysql> select Host,user,password from Mysql.user;
+-----------+------------------+-------------------------------------------+
| Host | user | password |
+-----------+------------------+-------------------------------------------+
| localhost | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |
| Mza | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |
| 127.0.0.1 | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |
|                  localhost |                                           | |
|                  Mza |                                           | |
| localhost | Debian-sys-maint | *19df6bf8310d46d681ae072ab73ecec99c018c19 |
| %         | Appadmin | *2470c0c06dee42fd1618bb99005adca2ec9d1e19 |
+-----------+------------------+-------------------------------------------+
7 Rows in Set (0.00 sec)
However, after you delete those that are empty (anonymous), you still cannot log on. (Probably because it didn't restart MySQL) and had to look at the MySQL reference manual. Find out which additions to the user section have this passage:
Two of these accounts have the same username Monty and password Some_pass. Two accounts are super user accounts with full privileges to do anything. An account (' Monty ' @ ' localhost ') is only used when connecting from the local computer. Another account (' Monty ' @ '% ') can be used to connect from other hosts. Please note that Monty's two accounts must be able to connect to Monty from any host. Without a localhost account, when Monty is connected from the local computer, the anonymous user account of localhost created by mysql_install_db will be preempted. As a result, Monty will be treated as an anonymous user. The reason is that the host column value of the anonymous user account is more specific than the ' Monty ' @ '% ' account, which is preceded by the user table sort order.
This passage is very clear, so execute Grant Select,insert,update,delete on test.* to [email protected] "localhost" identified by "password";
Log in with Appadmin after exiting, success. Ext.: http://anonymity.iteye.com/blog/347737

MySQL new user cannot log on locally

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.