mysql is a simple SQL shell with input line editing capabilities. It supports interactive and noninteractive use. When used interactively, query results are presented in an ASCII-table format.
The error 'MySQL is not running' in cPanel is one of the common error that we come across. Yes, we do understand this to be very annoying.
Generally, this error causes if MySQL is not stopped properly. This means when a systemd sends a command for the MySQL to start, the MySQL launches, and then it populates a lock for the subsystem. But then it stops with an error.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to fix MySQL related errors.
In this context, we shall look into steps to fix this MySQL error.
Steps to resolve MySQL is not running problem?
Apply the tips below to fix this error in cPanel.
1. Removing the lock file to fix MySQL error
One of our customers approached telling us that MySQL was not working well.
Our Support Experts started to troubleshoot the error by checking the MySQL status using the below command:
# service mysql status
MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED]
And the above was the status of MySQL telling us that MySQL was not running.
So our Support Experts ran the below command to remove the lock file:
rm /var/lock/subsys/mysql
Then, we restarted the MySQL service using the below command:
# service mysqld restart
This fixed the error.
2. MySQL stops running if tables crash
Another reason for this error to occur is due to the database tables crashing. Normally, the below message displays in the MySQL error logs:
MyISAM-table '/var/lib/mysql/dbname/table_name.MYI' is marked as crashed and should be repaired
We can fix this problem by repairing the database and the database tables using the below commands:
# myisamchk <database> <server>
# mysqlcheck -r <database> <postname>
Then, we restart the MySQL service using the command:
# service mysqld restart