Home >Database >Mysql Tutorial >How to start and stop the MySQL service on Linux server
MySQL is a popular relational database management system that is widely used in many applications and websites. Whether as a developer or system administrator, mastering the basic operations of MySQL is necessary. One of the most basic operations is starting and stopping the MySQL service.
The starting and stopping process of MySQL is very simple. In this article, we will show you how to start and stop the MySQL service on a Linux server.
There are two ways to start the MySQL service on the Linux server: using the command line tool and using the self-starting script.
You can use command line tools to start the MySQL service. Please follow these steps:
sudo service mysql start
$ sudo service mysql start * Starting MySQL database server mysqld ...done.
Another way to start the MySQL service Is using a self-starting script. This will automatically start the MySQL service when your system boots.
Please follow these steps:
sudo nano /etc/mysql/my.cnf
[mysqld] should_restart_mysql = yes
This will ensure that MySQL starts automatically when the system starts.
sudo update-rc.d mysql defaults
$ sudo update-rc.d mysql defaults Adding system startup for /etc/init.d/mysql ... /etc/rc0.d/K20mysql -> ../init.d/mysql /etc/rc1.d/K20mysql -> ../init.d/mysql /etc/rc6.d/K20mysql -> ../init.d/mysql /etc/rc2.d/S20mysql -> ../init.d/mysql /etc/rc3.d/S20mysql -> ../init.d/mysql /etc/rc4.d/S20mysql -> ../init.d/mysql /etc/rc5.d/S20mysql -> ../init.d/mysql
There are also two ways to stop the MySQL service on the Linux server: using command line tools and using self-starting scripts.
You can use command line tools to stop the MySQL service. Please follow these steps:
sudo service mysql stop
$ sudo service mysql stop * Stopping MySQL database server mysqld ...done.
Another way to stop the MySQL service Is using a self-starting script. This will automatically shut down the MySQL service when your system shuts down.
Please follow these steps:
sudo nano /etc/mysql/my.cnf
[mysqld] should_restart_mysql = no
This will ensure that MySQL automatically shuts down when the system shuts down.
sudo update-rc.d mysql remove
$ sudo update-rc.d mysql remove Removing any system startup links for /etc/init.d/mysql ... /etc/rc0.d/K20mysql /etc/rc1.d/K20mysql /etc/rc2.d/S20mysql /etc/rc3.d/S20mysql /etc/rc4.d/S20mysql /etc/rc5.d/S20mysql /etc/rc6.d/K20mysql
Starting and stopping the MySQL service on a Linux server is a simple yet important task, which is necessary for both database developers and system administrators. In this article, we have shown you how to start and stop the MySQL service using command line tools and self-start scripts. Choose the method that works for you and always ensure that your MySQL service is available and secure.
The above is the detailed content of How to start and stop the MySQL service on Linux server. For more information, please follow other related articles on the PHP Chinese website!