Cannot log in with created user in mysql

前端 未结 12 1753
小蘑菇
小蘑菇 2020-12-07 15:31

Using this command

GRANT ALL PRIVILEGES ON *.* to \'brian\'@\'%\' identified by \'password\';

I try to login with:

 mysql -         


        
12条回答
  •  离开以前
    2020-12-07 15:53

    The mysql docs have this to say: (from http://dev.mysql.com/doc/refman/5.1/en/adding-users.html):

    Two of the accounts have a user name of monty and a password of some_pass. Both accounts are superuser accounts with full privileges to do anything. The 'monty'@'localhost' account can be used only when connecting from the local host. The 'monty'@'%' account uses the '%' wildcard for the host part, so it can be used to connect from any host.

    It is necessary to have both accounts for monty to be able to connect from anywhere as monty. Without the localhost account, the anonymous-user account for localhost that is created by mysql_install_db would take precedence when monty connects from the local host. As a result, monty would be treated as an anonymous user. The reason for this is that the anonymous-user account has a more specific Host column value than the 'monty'@'%' account and thus comes earlier in the user table sort order.

    With this in mind I would recommend you create a 'brian'@'localhost' user with the same privileges.

提交回复
热议问题