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 or sudo /etc/init.d/mysqld start
Commands to stop the MySQL server
sudo service mysqld stop or sudo /etc/init.d/mysqld stop
To restart the MYSQL server
sudo service mysqld restart or 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:
For MySQL
systemctl restart mysqld
For MariaDB
systemctl restart mariadb
Other Useful Resources
- How to start, restart & stop Apache & MySQL server on Ubuntu
- How to Change MySQL user password in Linux
- Comparison between CentOS, Debian, and Ubuntu
- Install Apache web server on CentOS 7/6 with a single command
- Install phpMyAdmin on Centos 7 & Centos 6
- How to Setup Ubuntu Root User Password Using Command
Related Posts
Rufus for linux? Not available, Use these best alternatives
Vboxmanage command not found in Windows CMD or PowerShell
8 Best ways to start Command Prompt in Windows 10
How to show hidden files in Windows 10 using Command prompt
How to install CentOS 8 on WSL 1 or 2 of Windows 10
How to install Plex media server on Windows 10 using just one command