MySQL service cannot be started-troubleshooting, mysql startup

Source: Internet
Author: User

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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.