MySQL service cannot be started-troubleshooting, mysql startup
Symptoms: the following ERROR occurs when you log on to MySQL after deleting a few unused databases in MySQL the previous day: mysql-u root-ppasswd ERROR 2002 (HY000 ): can't connect to local MySQL server through socket '/var/run/mysqld. sock 'view/var/run/mysqld. sock does not exist at all. There are several possible causes for mysqld. sock does not exist: 1. mysql-server2 not installed. if mysql-server is installed and it is running, you need to check the configuration file for details, you can see the stack overflow answer: 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, however, ps-aux | grep 'mysql' finds that the mysql service is not enabled. However, the following error occurs: start: Job failed to start and/var/log/mysql/error. log is empty, can not be based on the log error; on the stack overflow to see similar to re-secure mysql-server but also save the original database data method: http://stackoverflow.com/questions/22909060/mysql-job-failed-to-start steps: 1. back up the original database data file to prevent installation from being successful:
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 content
sudo rm /etc/mysql/ -R
4. Check whether the original database file is still in/var/lib/mysql/. If no file exists, copy the file saved in step 1 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 check whether the original data exists
mysql -u root -ppasswdmysql> show databases -> ;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sql |+--------------------+4 rows in set (0.00 sec)
Now, mysql is back to its original state;