Before making any changes, it's always good practice to check the current status of your MySQL service:
service mysqld status
# Or directly with:
systemctl status mysqld
What to look for:
Active: active (running) - MySQL is currently running
Main PID - The process ID of the MySQL daemon
Uptime information - How long the service has been running
Memory and CPU usage statistics
You can also verify using the process list:
ps -ef | grep mysqld
When you need to stop MySQL for maintenance, updates, or troubleshooting:
service mysqld stop
# Alternative:
systemctl stop mysqld
What happens:
Systemd sends a stop signal to the MySQL process
MySQL performs a graceful shutdown, completing any pending transactions
The service status changes to inactive (dead)
All MySQL processes are terminated
Verification:
After stopping, always verify the service status:
service mysqld status
You should see Active: inactive (dead) confirming the service has stopped.
To start MySQL after maintenance or when needed:
service mysqld start
# Alternative:
systemctl start mysqld
What happens:
Systemd executes the MySQL startup sequence
MySQL daemon starts with the configured options
The service becomes active and ready to accept connections
Verification:
Check that MySQL started successfully:
service mysqld status
Look for Active: active (running) and "Server is operational" in the status message.
Restarting MySQL Service
For configuration changes or to refresh the service:
service mysqld restart
# Alternative:
systemctl restart mysql
The standard service mysqld stop performs a graceful shutdown. In cases where MySQL is unresponsive, you might need to use:
systemctl kill mysqld
# Or as last resort:
kill -9 [mysql_pid]