I have MySQL installed in a Docker container and I'm tying to log in and it just won't accept my credentials.
I'm careful to copy paste my password.
I retyped everything fearing some hidden character somewhere... no luck.
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> grant all privileges on db_thalasoft.* to thalasoft@'%' identified by 'XXX';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> quit;
Bye
root@89b59e4faab5:/usr/bin/mysql/install# bin/mysql -u thalasoft -p
Enter password:
ERROR 1045 (28000): Access denied for user 'thalasoft'@'localhost' (using password: YES)
The version is a self built one from the mysql-5.6.30.tar.gz
archive.
TLDR : wild card %
does not include special host localhost
.
You need to create a login for the special host localhost
to indicate a login from the local host (from the MySQL server point of view). The %
is a wild card for IP addresses in case you are using an IP to connect to the host (or force the access via TCP with the --protocol=tcp
option). So when you connect via local sockets (which will be used when you don't provide a host in the command line) you must have a user which is configured for the localhost
host. See 6.2.3 Specifying Account Names :
A host value can be a host name or an IP address (IPv4 or IPv6). The name
'localhost'
indicates the local host. The IP address'127.0.0.1'
indicates the IPv4 loopback interface. The IP address'::1'
indicates the IPv6 loopback interface.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.