database users with host=% cannot connect from localhost

Problems with the Linux version of XAMPP, questions, comments, and anything related.

database users with host=% cannot connect from localhost

Postby matteosistisette » 20. January 2012 20:58

Hi,

When I create a new database user in phpMyAdmin, if I set the host to "%" (any host), the user won't be able to connect from localhost. For example, if some php script uses that username to connect to mysql, it will not be able to connect. I am forced to set the host to "localhost" when I create the user, and it works, but this is annoying because it will allow the user to connect only from localhost.

Note that this only happens with Xampp. With any other server I have ever tried, "any host" works just fine.

Is there a fix for this?

thanks
m.
matteosistisette
 
Posts: 38
Joined: 11. January 2011 12:22
XAMPP Version: 5.6.3
Operating System: Windows 7 64bit; Ubuntu 11.10

Re: database users with host=% cannot connect from localhost

Postby Altrea » 20. January 2012 23:05

Hi,

MySQL does have predefined anonymous (means: not defined) usernames and hostnames and use them in a definite order.
The more precise a user is, the higher is his priority.

Means:
John@Doe (User John at Host Doe) = highest priority
%@Doe (Any User at Host Doe)
John@% (John at any Host)
%@% (any User at any Host) = lowest priority

Because there is already a rule for %@localhost it has a higher priority than your user@% rule.

The easiest way to get around that is to define the user for localhost too.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6834
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: Windows 10 Pro x64

Re: database users with host=% cannot connect from localhost

Postby matteosistisette » 20. January 2012 23:25

What is the rule that is defined for %@localhost (which is taking priority over givenuser@%)?

And why does this happen only with xampp? Is this a rule that is not present by default on common server configurations but it is in xampp? What's the rationale behind it?

thanks
m.
matteosistisette
 
Posts: 38
Joined: 11. January 2011 12:22
XAMPP Version: 5.6.3
Operating System: Windows 7 64bit; Ubuntu 11.10

Re: database users with host=% cannot connect from localhost

Postby Altrea » 20. January 2012 23:34

matteosistisette wrote:why does this happen only with xampp? Is this a rule that is not present by default on common server configurations but it is in xampp? What's the rationale behind it?

The anonymous account is created by default in every mysql installation.
Most productive servers don't permit access by anonymous to mysql servers, so this users are deleted.

More to read here: http://dev.mysql.com/doc/refman/5.5/en/ ... users.html
(especially the part which starts with "The accounts created by these statements have the following properties:"

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6834
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: Windows 10 Pro x64

Re: database users with host=% cannot connect from localhost

Postby JonB » 21. January 2012 17:12

Thanks for the informative answer, Altrea -- one I did not know! :shock:

Good Job
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
XAMPP Version: 1.8.3-2
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: database users with host=% cannot connect from localhost

Postby matteosistisette » 21. January 2012 18:03

Thank you!
matteosistisette
 
Posts: 38
Joined: 11. January 2011 12:22
XAMPP Version: 5.6.3
Operating System: Windows 7 64bit; Ubuntu 11.10

Re: database users with host=% cannot connect from localhost

Postby Altrea » 21. January 2012 20:03

You are both very welcome :)
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6834
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: Windows 10 Pro x64


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 4 guests