New mysql user cannot log on locally

Source: Internet
Author: User

The new mysql user cannot log on locally. Because the root permission is too high, the new user appadmin has the permission only for the database to be used. The creation statement is as follows: grant select, insert, update, delete on test. * to appadmin @ "%" identified by "password"; where @ "%" can be logged on at any address. After the user is created, go to mysql. user to view the user. However, if you use mysql-u appadmin-ppassword to log on, the system prompts "ERROR 1045 (28000): Access denied for user 'appadmin' @ 'localhost' (using password: YES)" cannot be logged on) some of them said, "mysql. there are other records in the user table, which are most likely to have a ''@ localhost record, that is, the username is empty, and the host field is the localhost record." Affected. Check the table.

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, users who are empty (anonymous) cannot log on after deletion. (Probably because mysql was not restarted) so I had to be patient and read the mysql reference manual. It is found that the added user has the same username and password some_pass for the two accounts. Both accounts are superuser accounts and have full permissions to do anything. An account ('monty '@ 'localhost') is only used for connection from the local machine. Another account ('monty '@' % ') can be used to connect from other hosts. Note that the two accounts of monty must be able to connect to monty from any host. There is no localhost account. When monty is connected from the local machine, the anonymous user account of localhost created by mysql_install_db takes the lead. As a result, monty is considered an anonymous user. The reason is that the Host column value of the anonymous user account is more specific than that of the 'monty '@' % 'account, so that it is ranked first in the sorting order of the user table. Therefore, grant select, insert, update, delete on test. * to appadmin @ "localhost" identified by "password"; log out and use appadmin to log on successfully.
 

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.