When MariaDB gets stuck at "activating (start)", it typically indicates the service is attempting to initialize but encountering an underlying issue. The systemd status output shows the mysqld process is running (PID 10759), but never completes the startup sequence.
First check the full MariaDB error logs (they often contain more details than systemd):
sudo journalctl -u mariadb.service -b --no-pager | grep -i error
sudo tail -n 100 /var/log/mysql/error.log
From experience with Ubuntu 19.10 specifically, these are frequent culprits:
- Corrupted InnoDB tablespace
- Incorrect permissions on /var/lib/mysql
- Conflict with AppArmor/SELinux
- Missing systemd dependencies
1. Force-stop the hanging service:
sudo systemctl kill -s SIGKILL mariadb.service
sudo systemctl reset-failed mariadb.service
2. Verify data directory ownership:
sudo chown -R mysql:mysql /var/lib/mysql
sudo chmod 750 /var/lib/mysql
3. Check for disk space issues:
df -h /var/lib/mysql
ls -lh /var/lib/mysql/ibdata*
If basic fixes don't work, try starting MariaDB in recovery mode:
sudo mysqld_safe --skip-grant-tables --skip-networking &
Then examine InnoDB status:
mysql -e "SHOW ENGINE INNODB STATUS\G"
Add these to /etc/mysql/mariadb.conf.d/50-server.cnf under [mysqld]:
innodb_force_recovery = 1
innodb_buffer_pool_size = 128M
systemd_cgroup = yes
After making changes:
sudo systemctl daemon-reload
sudo systemctl start mariadb.service
timeout 30s bash -c 'while ! systemctl is-active mariadb.service; do sleep 1; done'
When trying to start MariaDB on Ubuntu 19.10 using systemctl start mariadb.service
, the command hangs indefinitely at the "activating (start)" stage. The service status shows:
Active: activating (start) since Mon 2020-04-20 08:44:57 IST; 5min ago
Main PID: 10759 (mysqld)
Tasks: 15 (limit: 4915)
Memory: 64.6M
First, let's check for any immediate errors in the MariaDB logs:
sudo journalctl -u mariadb.service -b
sudo tail -n 100 /var/log/mysql/error.log
Common issues that can cause this behavior include:
- Insufficient permissions on data directories
- Corrupted database files
- Incorrect configuration in my.cnf
- Incompatible InnoDB log files
1. Check Directory Permissions
MariaDB requires proper ownership of its data directories:
sudo chown -R mysql:mysql /var/lib/mysql
sudo chmod -R 755 /var/lib/mysql
2. Examine Configuration Files
Verify your MariaDB configuration isn't causing the hang:
sudo mysql --print-defaults
sudo cat /etc/mysql/my.cnf
sudo cat /etc/mysql/mariadb.conf.d/*
3. Try Safe Startup
Attempt starting MariaDB with minimal configuration:
sudo mysqld_safe --skip-grant-tables --skip-networking &
4. Debug Mode Analysis
Run MariaDB in debug mode to identify the exact hang point:
sudo mysqld --debug --console
Database Repair Procedure
If the issue stems from database corruption:
sudo mysqlcheck --all-databases --check-upgrade --auto-repair
sudo mysql_upgrade
InnoDB Recovery
Add these lines to /etc/mysql/my.cnf under [mysqld] section:
[mysqld]
innodb_force_recovery = 1
skip-slave-start
Then gradually increase innodb_force_recovery from 1 to 6 until the server starts.
Examine systemd's configuration override:
sudo cat /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
Try resetting systemd's configuration:
sudo systemctl daemon-reload
sudo systemctl reset-failed mariadb.service
As a last resort, perform a clean reinstall:
sudo apt purge mariadb-server mariadb-client
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
sudo apt install mariadb-server mariadb-client