Link to home
Start Free TrialLog in
Avatar of parlays
parlays

asked on

Can't start MySQL server on Ubuntu?

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.
Avatar of Maciej S
Maciej S
Flag of Poland image

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
Avatar of parlays
parlays

ASKER

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:
'/var/run/mysqld/mysqld.sock'

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!
ASKER CERTIFIED SOLUTION
Avatar of Maciej S
Maciej S
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
again ... simply ... do

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

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 :-)
Avatar of parlays

ASKER

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.
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.