Info2soft use cookies to help you have a superior and more admissible browsing experience on our website. Privacy Policy
Loading...
When you try to start MySQL on Linux, you may encounter an error message like:
Don’t worry, in this guide, we will explain the common causes of “Failed to start MySQL Community Server” and provide step-by-step solutions to help you diagnose and restore your MySQL server quickly.
The common “Failed to start MySQL Community Server” errors are as follows:
Before changing any configuration files or reinstalling MySQL, the first step is to identify why the MySQL service failed to start. The error message shown by systemd is usually only a general indication that the startup process failed. The detailed cause is typically recorded in the MySQL error log.
1. Check the Error Log
On Ubuntu and Debian-based systems, the default error log is usually located at:
/var/log/mysql/error.log
You can view the latest errors with:
sudo tail -50 /var/log/mysql/error.log
For real-time monitoring while restarting MySQL:
sudo tail -f /var/log/mysql/error.log
You can also use systemd logs:
sudo journalctl -xeu mysql.service
2. Check MySQL Service Status
Start by checking the current status of the MySQL service:
sudo systemctl status mysql
You may see an output similar to:
After checking the MySQL logs, you should have a more specific error message that points to the actual cause. Follow the solutions below and solve the problem.
Errors happen from time to time; to ensure business continuity, it is necessary to back up MySQL with Info2soft’s i2Backup. It allows you to back up all MySQL data from one console. Supports immutable backups, ransomware protection, and more. Learn More>>
One common reason for MySQL startup failure is that a directory specified in the MySQL configuration file does not exist.
If you see these in your error log:
mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
[ERROR] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files[reference:11]ls -la /vmfs/volumes
vmkfstools -i source.vmdk -d thin dest.vmdk
then MySQL is configured to use /var/lib/mysql-files as the secure file import/export directory, but that directory doesn’t exist on your system.
Here is how to fix it.
Step 1. Identify the MySQL user-Check:
Check /etc/mysql/my.cnf or /etc/mysql/mysql.conf.d/mysqld.cnf for the user directive. On Ubuntu/Debian systems, this is typically mysql.
Step 2. Create the missing directory
sudo mkdir /var/lib/mysql-files
Step 3. Set the correct ownership
sudo chown -R mysql:mysql /var/lib/mysql-files/
Step 4. Set appropriate permissions (optional but recommended)..
sudo chmod 700 /var/lib/mysql-files/
Step 5. Restart MySQL:
sudo systemctl start mysql
Once the directory exists with the correct ownership, MySQL will be able to access it and start successfully.
Incorrect ownership or permissions on MySQL files are another common cause of startup failures.
MySQL runs under the mysql system user. If database files, log directories, or configuration-related folders are owned by another user (such as root), MySQL may not have permission to access required files.
The error log might show Permission denied messages related to /var/lib/mysql or /var/log/mysql.
Here are how to fix it.
• Check Current Permissions
ls -ld /var/lib/mysql
The output should show mysql:mysql as the owner and group.
• Fix Ownership
If the ownership is incorrect, fix it with:
sudo chown -R mysql:mysql /var/lib/mysql
• Fix Permissions
Set appropriate directory permissions:
sudo chmod 750 /var/lib/mysql
Also check the log directory:
sudo chown -R mysql:adm /var/log/mysql
sudo chmod 750 /var/log/mysql
After fixing permissions, try starting MySQL again.
A misconfigured my.cnf file is another common cause of prevent MySQL Community Server from starting.
MySQL’s main configuration files are typically located at:
Typical configuration mistakes include:
Here are how to fix:
• Validate Your Configuration:
You can check for configuration errors with:
mysql --verbose –-help
Or more specifically:
mysqld --verbose –help
If there’s a syntax error, MySQL will typically print it when you try to start the service.
• Fix Configuration Errors
1. Open the configuration file:
sudo nano /etc/mysql/my.cnf
2. Look for any obvious error, like incorrect paths, misspelled directives, or values that seem out of range.
3. Save the file and exit.
4. Attempt to restart:
sudo systemctl restart mysql
If you’re unsure about a specific setting, comment it out temporarily (add # at the start of the line) and try starting MySQL without it.
• Option 1: Free the Port
Identify the process using port 3306 and stop it if it’s safe to do so.
• Option 2. Change MySQL’s port
Edit my.cnf and add or modify:
[mysqld]
port = 3307
Then restart MySQL.
If the MySQL error log contains messages related to InnoDB, such as:
The InnoDB redo logs become corrupted due to an improper shutdown or system crash. And the MySQL community server may fail to start.
How to fix it:
Step 1. Stop MySQL (if it is partially running):
sudo systemctl stop mysql
Step 2. Back up the existing log files:
sudo mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0.bak
sudo mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1.bak
Step 3. Start MySQL:
sudo systemctl start mysql
MySQL will automatically recreate the log files with the correct size and format
MySQL needs disk space to write temporary files, logs, and perform various operations. If your disk is full, MySQL won’t start.
• Check Disk Space
df -h
Look for partitions that are at 100% usage, particularly the partition containing /var/lib/mysql.
Steps to Free Up Space:
After freeing space, attempt to start MySQL again.
On Ubuntu systems, AppArmor can silently block MySQL from accessing certain files or directories. On Red Hat-based systems, SELinux can cause similar issues.
• Check for AppArmor Issues
Look for messages like this in journalctl:
apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld"[reference:28]
• Check AppArmor Status
sudo aa-status
Look for the MySQL profile and whether it’s in enforce or complain mode.
How to fix:
Option 1. Temporarily disable AppArmor for MySQL (for testing only):
sudo aa-disable /usr/sbin/mysqld
Option 2. Reload AppArmor profiles after making changes:
sudo systemctl restart apparmor
Option 3. For SELinux systems, set the correct security context:
sudo semanage fcontext -a -t mysqld_db_t "/var/lib/mysql-files(/.*)?"
sudo restorecon -Rv /var/lib/mysql-files
Hope the above solution can help you. To avoid the problem happening again, try the following best practices can help reduce the risk of MySQL service failures.
Troubleshooting errors like “Failed to Start MySQL Community Server” can help restore database availability, but preventing data loss requires a reliable backup and recovery strategy.
Unexpected MySQL failures can happen due to various reasons, including configuration mistakes, storage issues, hardware failures, accidental deletion, or database corruption. Without a recent and reliable backup, recovering a failed MySQL server can become a time-consuming and risky process.
i2Backup is an enterprise backup solution designed to protect critical databases, including MySQL, Oracle, SQL Server, and other business applications. It helps organizations automate database backup, simplify recovery operations, and maintain business continuity.
i2Backup’s main advantages:
1. Automated MySQL Backup and Recovery
i2Backup enables administrators to create scheduled backup policies and retention policies to automate MySQL data protection tasks.
2. Protect MySQL Data Against Unexpected Failures
When a MySQL service cannot start due to corruption, system failures, or configuration problems, having verified backups allows administrators to quickly restore databases to a previous healthy state.
i2Backup supports database backup and recovery with features such as: full and incremental backups, table-level recovery, and multiple backup storage targets. These capabilities help organizations reduce downtime and improve database resilience.
3. Centralized Management for Enterprise Environments
i2Backup provides centralized management through a graphical interface, allowing administrators to easily monitor backup jobs, view backup reports, manage backup policies, and more. This simplifies database protection in large-scale IT environments.
4. Support Multiple Storage Options and Disaster Recovery Scenarios
i2Backup supports backing up MySQL to tape, local disk, ZFS storage, object storage, and more, helping organizations build flexible backup and disaster recovery strategies.
By combining regular MySQL backups with proper recovery planning, organizations can minimize the impact of database failures and maintain continuous business operations.
Click the button below to request a 60-day free trial.
The “Failed to Start MySQL Community Server” error is a common MySQL startup issue, but the underlying cause can range from missing directories or incorrect permissions to configuration errors, disk space issues, or database corruption.
The most effective way to resolve the issue is to start with a systematic troubleshooting process: check the MySQL service status, review error logs, identify the specific cause of the failure, and apply the appropriate fix rather than making unnecessary changes.
However, restoring a failed MySQL service is only part of maintaining database availability. Unexpected failures, data corruption, and system issues can still put critical databases at risk. A reliable backup and recovery strategy helps ensure that your MySQL databases can be restored quickly when problems occur. Using Info2soft‘s i2Backup, organizations can minimize downtime, protect valuable data, and maintain more resilient MySQL environments.