3

I'm running Ubuntu 10.10 inside VMware fusion on Mac OSX Snow Leopard. Inside ubuntu, I'm attempting to use command-line mysql to connect to a database hosted on a separate web server. For some reason, mysql misinterprets the remote hostname as a local address, and is not able to connect to the database.

Steps: (from ubuntu inside VMware)

mysql -u <my-username> -h mysql-2.sandbox.wrkng.net -p

Enter Password: <my password>

expected: to log into mysql

got:

ERROR 1045 (28000): Access denied for user '<my-username>'@'c-71-233-98-90.hds1.ma.comcast.net' (using password: YES)

Note that the hostname referenced in the error message is different than the one I inputted to the mysql command.

Also, performing the same command from the Mac (host of the VM) terminal successfully connects to the database.

I am not seasoned with VMware or linux, so I may be missing something obvious here -- it seems like somewhere along the way either ubuntu or the VM has a networking issue. Note also that accessing the internet via ubuntu inside the VM works fine.

Any help is greatly appreciated. Thanks!

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
Nick Grossman
  • 31
  • 1
  • 2
  • The host name in the error message is not the same as the host given to the mysql command, because the error message is telling you that "some user, at this location, doesn't have a sufficient grant in place to do this, so I'm kicking them off". – Rob Jan 01 '11 at 20:51
  • When you're logged in successfully via the Mac terminal, what is the output of "SELECT CURRENT_USER()" ? – Rob Jan 01 '11 at 20:52
  • 1
    You need some form of name to IP translation -- HOSTS file, DNS, etc -- to be able to connect to a remote host. Make sure you can ping the host first... – OMG Ponies Jan 01 '11 at 20:56
  • This is better suited on http://serverfault.com/ – moinudin Jan 01 '11 at 21:20
  • 1
    Have you explicitly granted access to the user(and host) you're connecting from ? Note that the host you're connecting TO is the one you give on the command line, the error message states the host you're connecting FROM. – nos Jan 01 '11 at 21:31
  • (whoops hit enter too soon) Thanks for the responses. @Rob - when I run select current_user() I get: @173.236.128.0/255.255.128.0 @OMG Ponies: gotcha. I am able to ping the host from the ubuntu VM; but am not able to connect directly via the IP address. @nos: no I have not explicitly granted access for that user/host. I didn't realize I needed to do that, since connecting from other machines hadn't been a problem. I will check, but I'm not sure if I'll be able to make that change given that it's a shared hosting account. – Nick Grossman Jan 02 '11 at 01:26
  • Thanks again everyone - it was, in fact, an issue with setting permissions on the mysql database for that user/host combination. I was able to update it and it works now. I sincerely appreciate the help. – Nick Grossman Jan 02 '11 at 04:58
  • http://dev.mysql.com/doc/refman/5.1/en/account-names.html (and supporting documentation) is always a handy thing to keep around when manipulating grants in MySQL. – Rob Jan 02 '11 at 20:26

1 Answers1

0

had the same problem, but you just have to set the user you're using to be allowed from any host, easiest done from phpmyadmin under permssions,

oh and you have to tell mysql to allow connections from elsewhere:

edit /etc/mysql/my.cnf

change this line: bind-address = 127.0.0.1 to: #bind-address = 127.0.0.1 then restart mysql:

sudo service mysql restart and it will work.

Henrik Sandin
  • 113
  • 1
  • 2
  • 7