Cannot log in with created user in mysql

前端 未结 12 1410
小蘑菇
小蘑菇 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 16:11

    This is a problem caused by the anonymous users. Once I install MySQL I always run

    shell> mysql_secure_installation 
    

    and select to set/change the root password, remove anonymous users, disallow remote root login, remove the test database. This will remove the anonymous user and secure your installation. It should also solve the problem you have.

    0 讨论(0)
  • 2020-12-07 16:12

    I think 'Russell Silva' is right...

    I created an user by

    CREATE USER 'username'@'%' PASSWORD='userpassword';
    

    But I cannot login in this account.The console told me that

    ERROR 1045 (28000): Access denied for user 'username'@'localhost' (using password: YES)
    

    So I created an user with the same username except that changing '%' to 'localhost',and I could finally login in as 'username'. It's quite weird for me though.

    0 讨论(0)
  • 2020-12-07 16:12

    I had a similar problem attempting to connect to a Maria DB running on Ubuntu after upgrading to 17.04.

    The default was to listen only on localhost, 127.0.0.1.

    To make MySQL/Maria listen on all available ports and interfaces I needed to explicitly specify bind-address=0.0.0.0. I added this line to the end of the file /etc/mysql/my.cnf, i.e.

    ...
    [client-server]
    
    # Import all .cnf files from configuration directory
    
    !includedir /etc/mysql/conf.d/
    !includedir /etc/mysql/mariadb.conf.d/
    bind-address=0.0.0.0
    

    Then...

    sudo /etc/init.d/mysql restart 
    
    0 讨论(0)
  • 2020-12-07 16:13
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    0 讨论(0)
  • 2020-12-07 16:14

    You can also connect from another host and then the localhost anonymous user is bypassed and you can remove it and flush privileges:

    mysql -u brian -ppassword -h 'other_host_than_localhost'
    
    0 讨论(0)
  • 2020-12-07 16:18

    In my case it was due to me clicking "SSL: REQUIRE SSL" (in phpmyadmin). When I changed it to "REQUIRE NONE" I could log in.

    0 讨论(0)
提交回复
热议问题