# MySQL Server Start Failed: Troubleshooting Startup Errors

You attempt to start MySQL and it fails immediately:

bash
systemctl start mysqld
# Job for mysqld.service failed because the control process exited with error code.
# See "systemctl status mysqld" and "journalctl -xe" for details.

Or when running manually:

bash
mysqld --user=mysql
# mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13 - Permission denied)

The server won't start, and you need to diagnose the root cause quickly.

Introduction

This article covers troubleshooting steps and solutions for MySQL Server Start Failed: Troubleshooting Startup Errors. The error typically occurs in production environments and can cause service disruptions if not addressed promptly.

Symptoms

Common error messages include:

bash
systemctl start mysqld
# Job for mysqld.service failed because the control process exited with error code.
# See "systemctl status mysqld" and "journalctl -xe" for details.
bash
mysqld --user=mysql
# mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13 - Permission denied)

```bash # Find the error log location mysqld --help --verbose 2>/dev/null | grep -A 1 "Default options"

# Common locations cat /var/log/mysql/error.log cat /var/lib/mysql/$(hostname).err cat /usr/local/mysql/data/$(hostname).err ```

Common Causes

  • Configuration misconfiguration
  • Missing or incorrect credentials
  • Network connectivity issues
  • Version compatibility problems
  • Resource exhaustion or limits
  • Permission or access denied

Step-by-Step Fix

  1. 1.Check logs for specific error messages
  2. 2.Verify configuration settings
  3. 3.Test network connectivity
  4. 4.Review recent changes
  5. 5.Apply corrective action
  6. 6.Verify the fix

Step 1: Check the Error Log

The MySQL error log is your primary diagnostic tool:

```bash # Find the error log location mysqld --help --verbose 2>/dev/null | grep -A 1 "Default options"

# Common locations cat /var/log/mysql/error.log cat /var/lib/mysql/$(hostname).err cat /usr/local/mysql/data/$(hostname).err ```

Look for specific error patterns:

bash
[ERROR] Can't start server: Bind on TCP/IP port: Address already in use
[ERROR] Do you already have another mysqld server running on port: 3306?
[ERROR] Aborting

Step 2: Check for Port Conflicts

Another MySQL instance or process might be using port 3306:

```bash # Check what's using port 3306 netstat -tlnp | grep 3306 ss -tlnp | grep 3306 lsof -i :3306

# Kill any existing MySQL processes pkill -9 mysqld pkill -9 mysql ```

If another service is using the port, either stop that service or change MySQL's port:

ini
# /etc/my.cnf or /etc/mysql/my.cnf
[mysqld]
port = 3307

Step 3: Check Data Directory Permissions

Permission issues are a common cause of startup failures:

```bash # Check MySQL data directory ownership ls -la /var/lib/mysql/

# The directory should be owned by mysql user chown -R mysql:mysql /var/lib/mysql/ chmod 750 /var/lib/mysql/ ```

Check the MySQL user's home directory and tmp directory:

```bash # Check mysql user exists id mysql

# Create user if missing useradd -r -s /sbin/nologin mysql

# Check tmp directory permissions ls -la /tmp/ chmod 1777 /tmp/ ```

Step 4: Check Configuration File Syntax

Syntax errors in my.cnf can prevent startup:

```bash # Validate configuration syntax mysqld --validate-config

# Or use my_print_defaults my_print_defaults mysqld ```

Common configuration errors:

```ini # Wrong: Missing quotes for paths with spaces datadir = /var/lib/mysql data

# Correct: datadir = /var/lib/mysql-data

# Wrong: Invalid option name inno_db_buffer_pool_size = 1G

# Correct: innodb_buffer_pool_size = 1G ```

Check for conflicting options:

```bash # Check all config files that are loaded mysqld --print-defaults

# Common config locations cat /etc/my.cnf cat /etc/mysql/my.cnf cat /etc/mysql/conf.d/*.cnf cat ~/.my.cnf ```

Step 5: Check InnoDB Corruption

InnoDB corruption can prevent startup:

bash
[ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace database/table uses space ID: 54 at filepath: ./database/table.ibd
[ERROR] InnoDB: Cannot open tablespace database/table which uses space ID 54

Start MySQL in recovery mode:

ini
# Add to my.cnf under [mysqld]
[mysqld]
innodb_force_recovery = 1

Recovery levels: - Level 1-2: Minimal, allows SELECT and some operations - Level 3: More aggressive, may lose data - Level 4-6: Severe recovery, may have significant data loss

```bash # Start with recovery mode systemctl start mysqld

# If successful, dump data immediately mysqldump --all-databases --routines --triggers --events > backup.sql

# Stop and remove corrupted data systemctl stop mysqld rm -rf /var/lib/mysql/ibdata1 rm -rf /var/lib/mysql/ib_logfile*

# Reinitialize (WARNING: destroys all data) mysqld --initialize --user=mysql

# Restore from backup mysql < backup.sql ```

Step 6: Check Disk Space

Full disks prevent MySQL from writing logs and temp files:

```bash # Check disk usage df -h

# Check inodes (for small files issue) df -i

# Check MySQL data directory size du -sh /var/lib/mysql/

# Clean up old logs if needed rm -f /var/lib/mysql/mysql-bin.*.index # Then purge old binary logs from MySQL ```

Step 7: Check SELinux or AppArmor

Security modules can block MySQL access:

```bash # Check SELinux status getenforce

# Temporarily disable for testing setenforce 0

# Check SELinux context ls -Z /var/lib/mysql/

# Reset MySQL context restorecon -Rv /var/lib/mysql/

# For AppArmor (Ubuntu/Debian) aa-status apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld ```

Step 8: Check Missing Required Directories

MySQL needs certain directories to exist:

```bash # Check and create required directories mkdir -p /var/run/mysqld chown mysql:mysql /var/run/mysqld chmod 755 /var/run/mysqld

mkdir -p /var/log/mysql chown mysql:mysql /var/log/mysql chmod 750 /var/log/mysql

# Check tmpdir exists mkdir -p /tmp chmod 1777 /tmp ```

Step 9: Check Binary Log Issues

Corrupted binary logs can prevent startup:

```bash # Check for binary log errors in error log grep "binary log" /var/log/mysql/error.log

# Temporarily disable binary logging for recovery # Add to my.cnf [mysqld] skip-log-bin

# Or rename corrupted log files cd /var/lib/mysql mv mysql-bin.000001 mysql-bin.000001.corrupted ```

Step 10: Check for Table Corruption

MyISAM table corruption:

```bash # Check and repair MyISAM tables myisamchk -r /var/lib/mysql/database/*.MYI

# For severe corruption myisamchk -o /var/lib/mysql/database/*.MYI ```

For InnoDB, use recovery mode as described earlier.

Verification

After fixing the issue:

```bash # Start MySQL systemctl start mysqld

# Check status systemctl status mysqld

# Verify MySQL is listening netstat -tlnp | grep 3306

# Connect and verify mysql -u root -p -e "SELECT 1;"

# Check error log for clean startup tail -f /var/log/mysql/error.log ```

Look for these good signs in the error log:

bash
[Note] mysqld: ready for connections.
Version: '8.0.33'  socket: '/var/lib/mysql/mysql.sock'  port: 3306

Common Startup Error Quick Reference

Error MessageCauseSolution
Permission deniedWrong ownershipchown -R mysql:mysql /var/lib/mysql
Address already in usePort conflictKill existing process or change port
Can't find fileMissing datadirRun mysqld --initialize
Unknown variableBad configCheck my.cnf syntax
Disk fullNo spaceFree disk space
Table 'mysql.user' doesn't existUninitializedInitialize MySQL
InnoDB: Cannot open tablespaceCorruptionUse innodb_force_recovery

Prevention

  1. 1.Always backup before making configuration changes
  2. 2.Test config changes: mysqld --validate-config
  3. 3.Monitor disk space and set alerts
  4. 4.Keep error log accessible and check regularly
  5. 5.Use LVM or ZFS snapshots for quick recovery

```bash # Test startup without actually starting mysqld --user=mysql --verbose --help | head -20

# Always check logs after config changes systemctl restart mysqld && journalctl -u mysqld -n 50 ```

  • [Database troubleshooting: Fix Backup Exclusive Lock Table Production Writes ](backup-exclusive-lock-table-production-writes)
  • [Fix Connection Pool Leak Application Not Closing Issue in Database](connection-pool-leak-application-not-closing)
  • [Fix Connection Reset Idle Timeout Firewall Issue in Database](connection-reset-idle-timeout-firewall)
  • [Fix Connection Reset Idle Timeout Serverless Database Issue in Database](connection-reset-idle-timeout-serverless-database)
  • [Fix Connection String Encoding Special Characters Issue in Database](connection-string-encoding-special-characters)

<script type="application/ld+json"> { "@context": "https://schema.org", "@type": "TechArticle", "headline": "MySQL Server Start Failed: Troubleshooting Startup Errors", "description": "Resolve MySQL server startup failures. Fix permission errors, configuration issues, corrupted data files, and port conflicts.", "url": "https://www.fixwikihub.com/fix-mysql-start-failed", "publisher": { "@type": "Organization", "name": "FixWikiHub", "url": "https://www.fixwikihub.com" }, "author": { "@type": "Person", "name": "FixWikiHub Editorial Team" }, "datePublished": "2025-11-23T12:07:11.046Z", "dateModified": "2025-11-23T12:07:11.046Z" } </script>