Using this command
GRANT ALL PRIVILEGES ON *.* to \'brian\'@\'%\' identified by \'password\';
I try to login with:
mysql -
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.
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.
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
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
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'
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.