Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm quite new using mysql, so let me know if I'm missing something. I took some holidays, and when I got back to work and I tried to log in phpmyadmin I got a ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2).

I never had this problem, so I was browsing to look for a solution. I tried some things, and I'm afraid I touched too much. I couldn't solve the problem, and the I realized that I had some actualizations to be done, and I thought that they may be helpful for mysql. Then I also realized that when I was doing this actualizations first day, they stopped because I had a lack of space, so I restarted then. Then,when the system was configuring mysql, it didn't advance. I waited for a long time and then I just stopped it and restarted the computer. After it, I just tried to uninstall mysql with sudo apt-get remove mysql-server-5.1, and install it again, but it didn't work. Now I have 2 questions:

  1. What do you think it is happening? Should I remove mysql completely? What should I do?
  2. I'm afraid of losing my databases, is there anyway to recover the data?

Thank you very much in advance.


These are the messages:

alfonso@alfonso-laptop:/$ tail -F /var/log/syslog | grep 
Feb 15 15:08:01 alfonso-laptop init: mysql post-start process (15192) terminated with status 
Feb 15 15:08:01 alfonso-laptop init: mysql main process (15263) terminated with status 
Feb 15 15:08:01 alfonso-laptop init: mysql main process ended, 
Feb 15 15:08:31 alfonso-laptop init: mysql post-start process (15264) terminated with status 
Feb 15 15:08:31 alfonso-laptop init: mysql main process (15358) terminated with status 
Feb 15 15:08:31 alfonso-laptop init: mysql main process ended, 
Feb 15 15:09:01 alfonso-laptop init: mysql post-start process (15359) terminated with status 
Feb 15 15:09:01 alfonso-laptop init: mysql main process (15447) terminated with status 
Feb 15 15:09:01 alfonso-laptop init: mysql main process ended, 
Feb 15 15:09:32 alfonso-laptop init: mysql post-start process (15448) terminated with status 1

This is the content of error.log-old

110128 13:17:20 [Note] /usr/sbin/mysqld: Normal shutdown

110128 13:17:20 [Note] Event Scheduler: Purging the queue. 0 events
110128 13:17:20  InnoDB: Starting shutdown...
110128 13:17:22  InnoDB: Shutdown completed; log sequence number 0 590872
110128 13:17:22 [Note] /usr/sbin/mysqld: Shutdown complete

110214  2:08:18 [Note] Plugin 'FEDERATED' is disabled.
110214  2:08:19  InnoDB: Started; log sequence number 0 590872
110214  2:08:19 [Note] Event Scheduler: Loaded 0 events
110214  2:08:19 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.1.41-3ubuntu12.8'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)

--> Some links of similar problems

It seems it's a permissions problem... But I don't know which permissions I should change...

SOLVED --> mysql error 2002 "cannot connect to socket"

share|improve this question

closed as off-topic by Magellan, mdpc, Christopher Perrin, Andrew B, Falcon Momot Aug 12 '13 at 4:18

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – Magellan, mdpc, Christopher Perrin, Andrew B, Falcon Momot
If this question can be reworded to fit the rules in the help center, please edit the question.

If you removed mysql-server, then you've already lost your databases. – Paul Tomblin Feb 15 '11 at 13:24
You should end the line with mysql, i.e. tail -F /var/log/syslog | grep mysql otherwise the grep statement would be useless. – Fabio Feb 15 '11 at 14:21
Are you on Ubuntu? There's a lot of thread for ubuntu if you google for "mysql post-start process terminated with status 1". You should check the content of /etc/init.d/mysql script to see what does it do. And then also search in the log directory for mysql.err file or something similar. – Fabio Feb 15 '11 at 14:29
Sorry, I didn't copy well, but it ended with mysql. I'm in Ubuntu 10.04, and I will check everything you commented. The log files (mysql.err included) are empty, unless 'error.log-old', that is in /var/log/mysql, I copy the content in the answer, but it doesn't tell me anything. I will browse about the threads u told me in google. Thank you very much! – sitonico Feb 15 '11 at 14:40
Solved -->… Thanks for your help. I learned a lot with your help in this question. – sitonico Feb 16 '11 at 13:58

You could try typing in the command sudo mysqld start in your terminal

Check the host setting, set it to "localhost", otherwise the server isn't reachable when your IP-address changes.

share|improve this answer
I already typed several times this command, and it didn't work. Could you please tell me where I can find this host setting? I think I have everything set up as 'localhost', nvertheless. thanks for your help! – sitonico Feb 15 '11 at 13:35
type nano /etc/mysql/my.cnf and look for the line bind-address = ..... change to bind-address = localhost – rndom Feb 15 '11 at 13:43
I changed it but still doesn't work. Thank you – sitonico Feb 15 '11 at 14:10
Sorry, forgot to mention you've got to restart the mysql server – rndom Feb 15 '11 at 14:15
I typed sudo service restart and I'm still waiting it to finish... Is this normal?? EDIT: It finished... but still not working... :( – sitonico Feb 15 '11 at 14:28
  1. Look at the mysql logs to see if there is a specific error. Probably in /var/logs/ somewhere.
  2. Your databases are probably in the /var/lib/mysql/ directory. If there are files and directories in there you probably haven't lost anything. First thing I would do is make a copy of everything in that directory to a safe place.

Depending on what you find in the logs you should look at this question on how to recover a failed mysql database.

share|improve this answer
For the first point, I have some logs in this folder, in fact several, but they all seem to be empty... maybe because of the remove I lost all the logs? For the second point, I found some files but in usr/bin .. files as mysql,mysqlaccess,mysqladmin... is this what you mean? thanks for your help! – sitonico Feb 15 '11 at 13:56

Normally apt-get remove doesn't remove data nor configuration files (as opposite of purge), if you're on Debian you can find databases file in /var/lib/mysql directory, if this dir is not empty the first thing you should do is to make a backup copy with rsync -av /var/lib/mysql /path/to/backup/. After that you can try to recover your installation.

If you removed the package you should reinstall it and then look into /var/log directory for any error message. You can start a terminal and as root type tail -F /var/log/syslog | grep mysql, after that on another terminal try to start mysql server with /etc/init.d/mysql start and look for error messages in the first window. Then post them here.

share|improve this answer
I could recover the data (I guess). I edit with the error messages so far – sitonico Feb 15 '11 at 14:11

If you did an apt-get remove mysql-server then your databases are still in /var/lib/mysql as the remove function of apt-get only removes the application but none of it's configuration files and data. Only apt-get purge removes everything i.e. application, configuration files, and data.

Reinstall mysql-server and then execute:

sudo service mysql start

to start the mysql server.

From there you should be able to log in to mysql using your previous user accounts or root.

Since you ran out of disk space you should run a repair (assuming they are myisam) on all of your tables to verify their integrity. If all of your tables are innodb, then I would mysqldump everything, stop mysql, delete the ib* files, restart mysql, and import the dump to ensure everything is clean.

share|improve this answer

have you verified that the MySQL server is running?

Verify using ps -ef | grep mysql.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.