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

I can't connect to mysql database becase it alway change 192.168.1.101 to ubuntu.local.

$ mysql -uroot -padmin1234 -h192.168.1.101
ERROR 1045 (28000) : Access denined for user 'root'@'ubuntu.local' (using password: YES)

How do I solve this problem.

File: /etc/hosts in this machine

127.0.0.1   localhost
127.0.1.1   ubuntu.ubuntu-domain    ubuntu

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

I have no idea about "root'@'ubuntu.local", where is it come from.

share|improve this question

migrated from stackoverflow.com Oct 1 '09 at 10:37

This question came from our site for professional and enthusiast programmers.

add comment

4 Answers

The "ubuntu.local" probably comes from the MySQL server machine, not the client from which you are trying to connect. Check /etc/hosts on that machine for an entry relating to 192.168.1.102 (or whatever your client machine's IP is). It may also (unlikely) be getting that name from Reverse DNS set up somewhere (maybe your router?).

The access denied statement is simply MySQL declining the host/username/password . Try

select * from mysql.users where user = 'root';

And see if anything comes back listing the client machines IP address or hostname. Make sure the passwords are the same (root@localhost can have a different password than root@someothermachine.com).

share|improve this answer
add comment

Use localhost instead of 192.168.1.101

In fact, why specify it at all?

You may be trying to login to mysql as root, but the error message indicates you're logged into Ubuntu as root also. This is not necessary. The two 'root' users are entirely different.

Log into Ubuntu as a normal user. Then log into mysql as root (is that the right password for the mysql root user? Did you assign the mysql root password when you installed mysql? If you didn't then it probably has no password).

Then assign rights (GRANT) for the normal Unbuntu user to access mysql.

share|improve this answer
    
@pavium 192.168.1.101 != localhost it is another machine and i'm loged in as normal user not root –  bugbug Oct 1 '09 at 8:21
1  
Ah I see ... so you're trying to connect to mysql on 192.168.1.101 from your local machine, which mysql seems to refer to as ubuntu@local. Does the mysql root user have permissions (ie GRANTs) to login from ubuntu.local, and/or is the password correct? –  pavium Oct 1 '09 at 10:08
add comment

https://help.ubuntu.com/community/ApacheMySQLPHP

This link has all the info you need to configure you mysql on ubuntu to work, if you are trying to access it from another machine (non local).

Thanks,
Mahesh Velaga.

share|improve this answer
add comment

The resolution in the error is being performed by the remote server running MySQLd.

If your GRANT is specifying a hostname then the forward and reverse DNS need to match. Which it seems they don't regardless.

Check your GRANT and check DNS.

share|improve this answer
add comment

Your Answer

 
discard

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