How To Fix Mysql Crashing On Startup [Solved]

Issue Common Cause Recommended Fix
MySQL Service Won’t Start Port 3306 Conflict Kill existing process or change port
Black Screen on CLI Corrupt InnoDB Logs Delete ib_logfile0 and ib_logfile1
Permission Denied Wrong Data Directory Ownership Run chown -R mysql:mysql
Immediate Crash Configuration Syntax Error Validate my.cnf or my.ini

How to fix MySQL crashing on startup showing a black screen error.

What is MySQL Crashing on Startup?

MySQL crashing on startup occurs when the database service fails to initialize during the boot sequence. This prevents any connection to the database engine and stops your applications from functioning.

Users often report a “MySQL Black Screen” context. This refers to the Command Line Interface (CLI) hanging or remaining blank after executing a start command. It indicates that the process has stalled or exited prematurely without rendering an error message to the console.

The root cause is usually found in the system error logs. Common triggers include insufficient disk space, corrupted data files, or conflicting software occupying the default network ports.

Step-by-Step Solutions

1. Inspect the Error Logs

The first step is identifying the specific error code. MySQL logs every failed startup attempt in a dedicated log file.

# For Ubuntu/Debian
sudo tail -n 50 /var/log/mysql/error.log

# For CentOS/RHEL
sudo tail -n 50 /var/lib/mysql/hostname.err

2. Resolve Port 3306 Conflicts

MySQL cannot start if another service (or a ghost instance of MySQL) is using port 3306. You must identify and stop the process holding the port.

# Check for processes on port 3306
sudo netstat -tulpn | grep 3306

# Kill the conflicting process ID (PID)
sudo kill -9 [PID_NUMBER]

3. Repair Corrupted InnoDB Logs

If a crash happened during a write operation, the InnoDB log files might be inconsistent. Removing them (after a backup) forces MySQL to recreate them on the next successful start.

# Navigate to the data directory
cd /var/lib/mysql

# Move old log files to a backup location
sudo mv ib_logfile0 ib_logfile0.bak
sudo mv ib_logfile1 ib_logfile1.bak

# Attempt to restart the service
sudo systemctl start mysql

4. Fix File Permissions

MySQL requires specific ownership of its data folder to function. If permissions were changed manually, the service will crash immediately.

# Restore ownership to the mysql user
sudo chown -R mysql:mysql /var/lib/mysql
sudo chmod -R 750 /var/lib/mysql

# Restart the service
sudo service mysql start

5. Use InnoDB Force Recovery

If the database is severely corrupted, you can start MySQL in recovery mode to export your data. Edit your configuration file (my.cnf or my.ini) and add this line under the [mysqld] section:

innodb_force_recovery = 1

Once the service starts, dump your data, remove the recovery line, and perform a clean re-import.