MySQL - ERROR 1045 (28000): Access denied for user
The reason you could not login as repl@'%'
has to do with MySQL's user authentication protocol. It does not cover patterns of users as one would believe.
Look at how you tried to logged in
mysql -u repl -p123
Since you did not specify an IP address, mysql assumes host is localhost and tries to connect via the socket file. This is why the error message says Access denied for user 'repl'@'localhost' (using password: YES)
.
One would think repl@'%'
would allow repl@localhost
. According to how MySQL perform user authentication, that will simply never happen. Would doing this help ?
mysql -u repl -p123 -h127.0.0.1
Believe it or not, mysql would attempt repl@localhost
again. Why? The mysql client sees 127.0.0.1
and tries the socket file again.
Try it like this:
mysql -u repl -p123 -h127.0.0.1 --protocol=tcp
This would force the mysql client to user the TCP/IP protocol explicitly. It would then have no choice but to user repl@'%'
.
You should issue for localhost specific to it.
GRANT USAGE ON *.* TO 'repl'@'localhost' IDENTIFIED BY '123';
And try connecting.