Bobcares

How to fix MySQL “job failed to start” error

by | Aug 18, 2018

Bobcares.com provides Server Maintenance Services to web hosts, digital marketers and other online businesses.

As part of our services, we manage MySQL servers, and troubleshoot performance issues and server errors.

A common error we’ve seen while trying to start MySQL, usually after an upgrade or a migration is :

# service mysql start start job failed to start

 

What is MySQL “job failed to start” error?

MySQL depends on a lot of sub-systems like OS libraries, file system, disk and memory for its proper functioning.

If any of these components develop an issue, MySQL will fail to execute.

Try to start it will result in the “job failed to start” error.

 

What causes MySQL “job failed to start” error?

Here are a few top reasons we’ve seen:

 

1. Disk space/inode exhaustion

MySQL uses temporary tables to run queries. So, when MySQL is unable to create new tables, either due to disk space exhaustion or inode exhaustion, the startup script will fail.

In such cases, there might be an entry like this in the log file:

/usr/sbin/mysqld: Disk is full writing '/tmp/yg4KlP8o'

When we see this issue, we first find out if it is a case of the disk space getting full or the inodes getting over. Commands such as df -h and df -i comes in handy in such situations.

To resolve it, we find out and delete excess files like spam, old backups, etc. Some common space hogs are:

  • Old backups – We’ve seen VPS containers in which old backup archives and uncompressed files taking up almost 50% of disk space. Along with deleting these files, we prevent a recurrence of this issue by setting up disk space alerts, and fixing space issues before it can lead to a service failure.
  • Session and Cache files in /tmp – Some apps store session files in /tmp. Usually these files are automatically deleted. But there are times when apps crash mid-execution and these files remain in /tmp, and cause a space overage. We prevent such issues by using an automated /tmp cleaner.
  • Spam in mail queue – Some mail servers like Qmail create 4 files for each mail. When such servers are bombarded with thousands of mails, it can easily use up all the inodes in the server, leaving the server unable to create any new file.
  • Old apps and database dumps – We’ve seen web users store old copies of web apps and old SQL dumps in their document root. This can also be easily cleared to reclaim space.
  • .. and more – There can be a hundred other ways in which space is lost. We fix such issues by systematically analyzing space usage from the server root, and drilling down to the folder that uses the most space.

 

2. Wrong permissions

All MySQL files should be fully owned by the “mysql” user and all directories it needs access to should have write permission.

For example, MySQL needs write access to the /tmp partition to create temporary folders. If it doesn’t, a service restart will fail with the error:

/usr/sbin/mysqld: Can't create/write to file '/tmp/yg4KlP8o'

To fix this, we make sure the /tmp directory has “777” permissions.

This error can also happen if the mysql data folders & files (/var/lib/mysql in RedHat distros) doesn’t have the right permissions.

Both the user and group should be set to “mysql”.

 

3. Inadequate memory

VPS servers are usually provisioned with a hard limit on memory.

We’ve seen cases where when the server memory is exhausted, MySQL crashes, and then fails to start.

To fix this, we figure out which process uses memory the most, and tweak the service settings or the apps to cut down its usage.

For example, we’ve found PHP to be the top memory hog in many VPSs. It is usually caused by poorly coded scripts or plugins. We remove or replace these scripts with better ones and setup memory limits for execution that prevents PHP starving other processes.

In sites that have a legitimate increase in traffic, the only solution will be to upgrade the memory.

 

Other reasons

There are other causes for this error such as startup script errors, log file issues, and more.

If you are unable to resolve these on your own, it is best to seek the assistance of a database expert. Our MySQL admins are online 24/7. Click here to submit a support request.

 

Conclusion

The error in MySQL “job failed to start” can be caused by disk errors, memory limits, file system issues and more. Here we’ve listed the top 3 reasons for this error and how we fix them.

 

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

SEE SERVER ADMIN PLANS

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF