GICT knowledge base
How to Fix the Common MySQL Errors?
Published
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.
Related guides
Check MariaDB Versions and Compatibility on Shared Hosting
Check your actual MariaDB/MySQL server version, maintenance coverage and application requirements before requesting a shared-hosting upgrade or move.
MySQLHow to Monitor MySQL Database Server Performance
Learn how to monitor MySQL performance with 4 essential Linux command-line tools.
MySQLHow to secure MySQL connections with SSL on Ubuntu
MySQL allows remote connections and we must protect data transfer happeneing between servers with SSL. Follow this tutorial to learn how.
MySQLHow to set up High Availability WordPress with HyperDB
HyperDB is a drop-in plugin that allows you to set up High Availability WordPress site that can work with multiple database servers at once.
