0

I've created user 'demo' and granted privileges for 'demo'@'%'. I can log from any remote server, but when I try to connect from localhost, I get an error:

Access denied for user 'demo_@'%''@'localhost' (using password: YES)

It's quite strange to me, since '%', according to documentation, should match ANY IP address. The obvious solution is to create 2nd set of priviledges for 'demo'@'localhost', but I wonder, is this designed to work that way? Or it has something to do with the way the mysql client tries to connect to DB? (loopback network interface vs. real network interface). Can I connect from mysql client as 'demo'@'%' from the same machine?

--edit--

It has been suggested that my question is the same as Are Users 'User'@'%' and 'User'@'localhost' not the same?, however, it's not the case, because the accepted answer states:

User@% would allow access from all locations.

in my actual case, User@% would allow access from all locations except localhost. Because the answer comes from 2012, and in meantime we've got branch to MariaDB, I provide the exact version information:

 D:\xampp\mysql\bin>mysql --version mysql  Ver 15.1 Distrib
 10.1.16-MariaDB, for Win32 (AMD64)
Community
  • 1
  • 1
9ilsdx 9rvj 0lo
  • 7,955
  • 10
  • 38
  • 77
  • @Benjamin yes and now, the question might be different, but the accepted answer is not an answer to my question. The answer states that the '%' means all location, including localhost, which seems not to be the case here... – 9ilsdx 9rvj 0lo Jan 13 '17 at 10:59
  • `'user'@'%'` means `user` from all hosts. may be you are using a wrong username/password like `demo_` for `demo`. or you already have another user `'demo'@'localhost'` with another privilege. – bansi Jan 13 '17 at 11:04
  • @bansi no, I've used the same username and password and no demo@localhost user, simply '%' is not matching 'localhost'. But there were missing details, I'm actually using MariaDB from XAMPP package, it might change many things... – 9ilsdx 9rvj 0lo Jan 13 '17 at 11:07
  • @bansi might it be that localhost is **not** a host under windows? AFAIK you couldn't sniff on localhost in wireshark... my knowledge is a few years back in that domain, however... – 9ilsdx 9rvj 0lo Jan 13 '17 at 11:10
  • check your `C:\Windows\System32\drivers\etc\hosts` also try `nslookup localhost` it should resolve to `127.0.0.1` – bansi Jan 13 '17 at 11:15
  • Sorry, was my fault. This is definitely no duplicate. – Benjamin Jan 13 '17 at 13:11

1 Answers1

0

Try adding the skip-name-resolve option to the mysqld section in my.cnf. Maybe there is really a problem resolving from/to "localhost". With that option the server only uses IP adresses.

Benjamin
  • 544
  • 5
  • 21