How to restart Apache and MySQL in CentOS/RHEL/Fedora/Scientific Linux version

Intermittently we require to start, restart or stop the Apache web server or MYSQL server on CentOS. The CentOS/Red Hat is the most popular Linux OS used commercially as a server operating system in enterprises, cloud and hosting environments.

Here in this tutorial will let you know the commands those you can use in the CentOS terminal to Stop/start or restart the MySQL or Apache on CentOS.

Below given commands are meant to work specifically on CentOS /RHEL (Red Hat)/Fedora based Linux version 4.x/5.x/6.x or older.

Command to Start Apache in CentOS 

service httpd start

Stop Apache command 

service httpd stop

Command to Restart

service httpd restart

Now commands for the latest version CentOS 7.x /RHEL (Red Hat)

To start the Apacher server

systemctl start httpd.service

Stop command for Apache in CentOS 7

systemctl stop httpd.service

Restart command for Apache

systemctl restart httpd.service


How to Start/Stop or Restart the MySQL server in CentOS/RHEL/Fedora/Scientific Linux version

Commands to start or stop the MySQL or MariaDB server in Centos 4.x, 5.x, 6.x or older versions

To Start MySQL in CetnOS uses the below commands:

sudo service mysqld start 


sudo /etc/init.d/mysqld start

Commands to stop the MySQL server

sudo service mysqld stop 


sudo /etc/init.d/mysqld stop

To restart the MYSQL server

sudo service mysqld restart 


sudo /etc/init.d/mysqld restart

For the latest CentOS 7.x version use the below commands

The latest CentOS 7.x by default comes with MariaDB packages but the user can install the MySQL too. Here are the commands for both:

To start MariaDB

systemctl start mariadb

For MySQL the command will be:

systemctl start mysqld

To stop the MySQL or MariaDB the command will be: 

For MariaDB: 

systemctl stop mariadb

For MySQL: 

systemctl stop mysqld

In order to restart the Database serve MariaDB or MySQL follow the below:


 systemctl restart mysqld

For MariaDB

systemctl restart mariadb

Other Useful Resources