• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2183
  • Last Modified:

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.
0
parlays
Asked:
parlays
  • 4
  • 4
  • 2
1 Solution
 
Maciej SsysadminCommented:
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.
0
 
agamalCommented:
Need to be root to start Mysql Server ... or use sudo instead
0
 
parlaysAuthor Commented:
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!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

http://hervalicio.us/blog/2007/07/07/no-such-file-or-directory-tmpmysqlsock/
0
 
Maciej SsysadminCommented:
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.
0
 
agamalCommented:
again ... simply ... do

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

0
 
Maciej SsysadminCommented:
agamal: author already did that - see http:#a23665293, but as far as I can see, he wants to avoid this workaround.
0
 
agamalCommented:
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 :-)
0
 
parlaysAuthor Commented:
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.
0
 
Maciej SsysadminCommented:
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.
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now