We help IT Professionals succeed at work.

Can't start MySQL server on Ubuntu?

Medium Priority
Last Modified: 2013-11-15
Hello everybody!

I recently made a mistake and messed up my MySQL server on my local Ubuntu machine.  I've tried everything to get it to work but can't.  I uninstalled and reinstalled it but can't get it back to normal.

When I run '/etc/init.d/mysql start' it always says fail.  Weird thing is if I run that command with Sudo it starts the server.

Any advice on how to restore things and fix this is much appreciated.
Watch Question

Maciej Ssysadmin

So, are you running /etc/init.d/mysql start command as normal user? If so, then it's quite normal, that you cannot start mysql server - you have probably to little privileges to run mysql server.
What is exact command when this command fails?
You may also look at your mysql error log file.

Need to be root to start Mysql Server ... or use sudo instead


Gotcha, thanks guys.

The problem is that when i run 'mysql' or 'mysqladmin' from the command line it says

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

It cannot find it because the location of the socket file is:

All of the settings in the my.cnf file point to '/var/run/mysqld/mysqld.sock', so I have no idea how to get it to check that folder instead of 'tmp/mysql.sock'.  Maybe I am missing a config file or something.

The way I am getting it to work now is to set up a symbolic link from the 'tmp/mysql.sock' location to the actual socket file and that works.

But I would like to fix it the right way and have it look for the actual file.  Thanks!

I think this is how you will solve this issue ....

Are you sure, that your my.cnf file is read when mysql starts?
Hard (better) way is to run your mysql with strace (strace -eopen -omysqld-debug.file mysqld...). After running this command you end up with mysqld-debug.file in which you will have information on all files which mysqld tried to open. If there is my.cnf listed, then it's ok. If it's not - you've got answer.
If you don't want to run strace (or you don't have it and you don't want to install it), try changing some setting (other than the one about socket :)) and restart apache. Try changing for example port on which mysqld listens to connections from default (3306) to some other - let it be for example 13306. After this, check (with netstat -na) if mysqld listens od this new port, or on previous one.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

again ... simply ... do

ln -sf /var/run/mysql/mysqld.sock /tmp/mysql.sock

Maciej Ssysadmin

agamal: author already did that - see http:#a23665293, but as far as I can see, he wants to avoid this workaround.

that is exactly i don't understand ... this is not a work around this is the solution to this case over google :D:D

any way good luck :-)


I guess I did more research and found that the my.cnf file was missing in the /etc directory.  There was one in the /etc/mysql directory so I created a symbolic link to that one.

I guess the MySQL client made a mistake when installing and pointed to the main /etc direcotyr.
Maciej Ssysadmin

If provided suggestions was helpful, they should be accepted as a solution or at least assisted solution.
I wrote about checking which files are read during mysqld startup (strace command), and as I see I was right - proper my.cnf hadn't been read by mysqld, therefore I have to object on closing this question without accepting my comment as at least assisted solution.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.