Symptom: The previous day in MySQL deleted a few unused databases after logging in MySQL the following error occurred: Mysql-u root-ppasswd Error 2002 (HY000): Can ' t connect to local mysql server th Rough socket '/var/run/mysqld/mysqld.sock ' view/var/run/mysqld/mysqld.sock There's no such file. There are several reasons why Mysqld.sock does not exist: 1. Mysql-server2 is not installed. If Mysql-server is installed and it is already running, you will need to check the configuration file to see the answer to the Stack Overflow:/http stackoverflow.com/questions/11657829/ Error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-var-run at this time I found that although Mysql-server has been installed, but Ps-aux | grep ' MySQL ' found that the MySQL service was not turned on; however: sudo service MySQL start error: Start:job failed to start and/var/log/mysql/error.log is empty, cannot be based on day A method that looks like re-security Mysql-server but also saves the original database data on the stack overflow: http://stackoverflow.com/questions/22909060/ Mysql-job-failed-to-start approximate steps: 1. Back up the original database data file in case there is no successful installation:
sudo mkdir/home/<your username>/mysql/cd/var/lib/mysql/sudo cp */home/<your username>/mysql/-R
2. Clean up MySQL for reinstallation
sudo apt-get purge mysql-server-5.1 Mysql-common
3. Delete the/etc/mysql folder and its contents
sudo rm/etc/mysql/-R
4. Check that the original database file is still in/var/lib/mysql/if it does not exist copy the file saved in the first step to this file and change its owner and group to root;
sudo mkdir/var/lib/mysql/sudo chown root:root/var/lib/mysql/-rcd ~/mysql/sudo CP */var/lib/mysql/-R
5. Install the new MySQL server
sudo apt-get install Mysql-server
6. Reconnect to see if the original data exists
Mysql-u root-ppasswdmysql> Show Databases , +--------------------+| Database |+--------------------+| information_schema | | mysql | | performance_schema | | SQL |+----------- ---------+4 rows in Set (0.00 sec)
At this point, my MySQL back to the original state;
MySQL Service failed to start-problem handling