In this tutorial, we can discuss the most common MySQL errors that can be happened on your server and the possible fixes. If you are getting the “error establishing a database connection” error for all your website, then login to your server via ssh and check the MySQL service status. You can check the MySQL status by executing the following command:
# service mysql status
If MySQL is down, then execute the following command to start the MySQL service.
# service mysql start
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/server.pid).
In case you got the error again like “ERROR! The server quit without updating PID file, the try to find out all the currently running MySQL processes by sing the command given below:
Then kill all MySQL process.
# ps -ef | grep mysql
After you have found the MySQL processes, kill all of them
# Kill -9 PID
If the error still persists, try to move ib_log files to /tmp folder and try to start the MySQL service.
# mv /var/lib/mysql/ib* /tmp
Then try to start the MySQL service.
# service mysql start
If you check the MySQL error log and could see the below error, then please follow the below steps.
Check the MySQL error log in /var/lib/mysql/
mysqld started
[ERROR] /usr/sbin/mysqld: Table ‘./mysql/user’ is marked as crashed and should be repaired [ERROR] /usr/sbin/mysqld: Table ‘./mysql/user’ is marked as crashed and should be repaired [ERROR] Fatal error: Can’t open and lock privilege tables: Table ‘./mysql/user’ is marked as crashed and should be repaired mysqld ended
Then first try the below command.
# /scripts/mysqlup –force
In case you got the same error then try to start MySQL using the below command.
# service MySQL start –skip-grant-tables
Then repair the corrupted table using the command.
# cd /var/lib/mysql/mysql
# mysqlcheck -r mysql user
mysql.user
warning : Number of rows changed from 1558 to 1556
status : OK
Now its repaired, restart mysql.
root@ [/var/lib/mysql/mysql]# service mysql stop
Shutting down MySQLs [ OK ]
root@ [/var/lib/mysql/mysql]# service mysql start
Starting MySQL [ OK ]
You can also restart the MySQL service from WHM.
1) Login to WHM.
2) Navigate to Restart Services.
3) Now you can restart the MySQL service by clicking the icon “SQL Server(MySQL)”.
If you need any further assistance please contact our support department.