Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I know that there are similar questions, but I didn't find exactly what I'm looking for. Here's what happens and it's kinda strange:

[root@xxx xxx]# mysql -u profuser -ppwd -h 192.168.1.99
ERROR 1045 (28000): Access denied for user 'profuser'@'192.168.1.99' (using password: YES)

And 192.168.1.99 is my own IP. But when I use localhost or 127.0.0.1, it's OK:

[root@xxx xxx]# mysql -u profuser -ppwd -h 127.0.0.1
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 68
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> bye
[root@xxx xxx]# mysql -u profuser -ppwd -h localhost
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 69
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

I found this question, but it didn't help:

mysql> select host from user where user='profuser';
+--------------+
| host         |
+--------------+
| 127.0.0.1    | 
| 192.168.1.99 | 
| localhost    | 
+--------------+

I added my IP, as advised in the other question.

share|improve this question
    
possible duplicate of Mysql - Access denied for user 'root'@'x.x.x.x' –  Chris S Apr 15 '11 at 14:43
    
@Chris S - no, it's not :) I even used it in my question ( "I found this question, but it didn't help:" - there's a link on "here") –  Kiril Kirov Apr 16 '11 at 7:46
    
the password for the user 'root'@'192.168.1.99' is almost certainly wrong; which Randy's answer covers from that question. But I'm sure you read that already... –  Chris S Apr 16 '11 at 14:37

2 Answers 2

up vote 1 down vote accepted

Does the password hash match for the new user/host combo? Tweak your select statement: select host, password from user where user='profuser';

Anyway, what're you attempting to achieve? You're adding the -h 192.168.1.99 flag; this isn't necessary when connecting locally (as you've discovered). If you're going to want to connect over the network, then you'll need a user spec like 'root'@'192.168.1.%' or 'root'@'%', something to allow remote hosts; if you're just doing local connections then you don't need the -h.

share|improve this answer
    
Ha! I tried this query and it shows, that there's no password for 'profuser'@'192.168.1.99'! LOL! Thanks a lot. –  Kiril Kirov Apr 15 '11 at 14:48
    
"Anyway, what're you attempting to achieve?" - I know, that it's not necessary, but this is a configurable option for an application and I don't know if the client, that will use my app, knows that, so I needed to do some tests for such situation. Anyway, thanks again (: –  Kiril Kirov Apr 15 '11 at 14:49
    
@Kiril Fair enough! But yeah, the straight GRANT from that other question doesn't set the password by default. ;) –  Shane Madden Apr 15 '11 at 15:02

When adding a host manually using a query like INSERT INTO mysql.user ..., you must issue a FLUSH PRIVILEGES command to apply the changes.

share|improve this answer
    
I tried, it's not working –  Kiril Kirov Apr 15 '11 at 14:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.