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'm having issues connecting to my local mysql server currently, but I need help in being able to connect to mysql from other instances also.

Background: I have a java service that is installed on a single instance, along with mysql. Other instances will also have this java service that need to connect to mysql.

Currently my /etc/hostname shows:

ip-xx-xx-xx-xxx

What should I be using to connect? I tried localhost just to see if it could connect, and it didn't work. I tried just the local ip also, and that didn't work either.

If I just try and connect to mysql locally this works:

mysql -u root -p123

But this fails:

mysql -h localhost -u root -p123

(So it fails whenever I add the -h switch, localhost, 127.0.0.1 or the internal ip addresses all fail with the error: ERROR 1045 (28000): Access denied for user 'myuser'@'localhost' (using password: YES)

I tried just the local ip, that didn't work, and the string 'ip-xx.xx.xx.xxx' and that didn't work either.

I'm clearly doing something wrong, what should I do?

share|improve this question
    
Is your MySQL server configured to listen on any IP addresses? And if it is, is it doing so? –  Ladadadada Feb 23 '13 at 19:20
    
where can I verify this? –  Blankman Feb 23 '13 at 21:18
    
@Ladadadada ok my my.cnf has the bind address set to my ip xx.xx.xxx.xx, but I can't seem to connect using that. When I enter JUST the ip, I get this error: 'root'@'ip-xx-xx-xx-xxx.ec2.internal' not sure why it added ip and .ec2.internal ? –  Blankman Feb 23 '13 at 21:20
    
If you get an error message, you should read it. If you don't understand it, you should include it in your question. –  Ladadadada Feb 23 '13 at 22:07
    
@Ladadadada the error message is: ERROR 1045 (28000): Access denied for user 'myuser'@'localhost' (using password: YES) –  Blankman Feb 24 '13 at 2:09

1 Answer 1

Listening (TCP) ports can be found with sudo netstat -tlnp.

The reason for the name instead of the IP address is that EC2 supplies reverse DNS lookups and your IP address resolves to that name. MySQL can use reverse DNS lookups in authentication but this is not recommended as anyone who owns an IP address can set the reverse lookup to whatever they like, circumventing the source protection.

this error: 'root'@'ip-xx-xx-xx-xxx.ec2.internal'

That looks like half an error message, the first half probably said something like ERROR 1045 (28000): Access denied for user and the last part said (using password: NO).

The error message tells us two things:

  1. MySQL is running and is listening on that IP address and the default port.
  2. Either the username or password you are using is wrong. Possibly both.

If you haven't yet logged in or changed the password for MySQL, the default is for there to be a root user with no password. Leave off the -p option or, when it asks for your password, just hit Enter.

share|improve this answer
    
ok figured it out, the problem was I created the user before the database, so it didn't link it up it seems. –  Blankman Feb 24 '13 at 2:20

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.