Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Okay, so disclaimer: I'm an absolute mysql noob. Gimme any other development type area and I'm fine.

So, I just started using Ubuntu 12.04 an setup mysql. Never really used localhost since we have a staging environment at work that I usually access. However, a client had a really large DB dump that I needed to access and I didn't want to put in on the server for everyone to deal with so I tried to use localhost

Whenever I try to access it through MySQL Workbench I get an error so I had a look at a couple of articles online and tried a couple of different things but if I run the following command in the terminal, I get an error:

mysql -u root -p -h

Produces the following

ERROR 2003 (HY000): Can't connect to MySQL server on '' (111)

However, if I access mysql like so:

mysql -u root -p

and then enter my password, I can access mysql fine.

Here's what


contains at the moment (I've tried looking for other versions of this file). I've left out all the commented out bits for brevity's sake.

port            = 3306 
socket          = /var/run/mysqld/mysqld.sock

socket          = /var/run/mysqld/mysqld.sock 
nice            = 0

user            = mysql 
pid-file        = /var/run/mysqld/ 
socket          = /var/run/mysqld/mysqld.sock 
port            = 3306
basedir         = /usr 
datadir         = /var/lib/mysql 
tmpdir          = /tmp 
lc-messages-dir = /usr/share/mysql 

key_buffer              = 16M 
max_allowed_packet      = 16M
thread_stack            = 192K 
thread_cache_size       = 8

myisam-recover         = BACKUP

query_cache_limit       = 1M 
query_cache_size        = 16M

log_error = /var/log/mysql/error.log

expire_logs_days        = 10 
max_binlog_size         = 100M

quick quote-names 
max_allowed_packet      = 16M


[isamchk] key_buffer              = 16M

!includedir /etc/mysql/conf.d/
share|improve this question
Can you add the full command line of the running mysqld process, and the output of netstat -anp | grep 3306? – Flup Jun 11 '13 at 11:22

3 Answers 3

up vote 0 down vote accepted

When you log into mysql with

mysql -u root -p

please run this command


USER() reports how you attempted to authenticate in MySQL

CURRENT_USER() reports how you were allowed to authenticate in MySQL

I have discussed this before : how do I see which user I am logged in as in MySQL?

In your case, my guess would be that CURRENT_USER() is 'root'@'localhost'.

There are two things you need to connect to MySQL using

  • You need the user 'root'@'' defined. That's probably what USER() said.
  • You need to explicit use the TCP/IP protocol

To create the user, login to MySQL and run SHOW GRANTS;

Whatever comes backup, copy and paste it into an editor, replace localhost with, command the edited command into mysql and execute it.

Now, to login using TCP/IP do this:

mysql -u root -p -h --protocol=tcp

Once you login, run SELECT USER(),CURRENT_USER(); and you will see something different.

Give it a Try !!!

share|improve this answer
Great answer. I'm not sure it's working @ 100% at the moment but I'm sure it will. I just don't have the time to check right now. I will post back. Gave you the up vote because of your detail. Nice!! – Kyle O'Brien Jun 18 '13 at 9:08

check whether mysql server is running, configured firewall allowing mysql server port.check this link also

share|improve this answer

Read this and check your firewall configuration.

share|improve this answer

Your Answer


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.