Home >Database >Mysql Tutorial >How to start and shut down MySQL

How to start and shut down MySQL

WBOY
WBOYforward
2023-05-27 17:37:061052browse

1. Start MySQL

There are two ways to start MySQL, one is to start using the command line, the other is to use the service to start .

1. Start using the command line

Enter the following command on the command line to start MySQL:

$ sudo systemctl start mysql

After successful startup, you can check the status of MySQL through the following command:

$ sudo systemctl status mysql

If the status is normal, "Active: active (running)" will be output, indicating that MySQL has been started successfully.

2. Use service startup

MySQL can also be started using service. This is the more common method because it can more conveniently manage the startup and shutdown of MySQL.

Starting MySQL using a service requires installing the MySQL service. You can install it through the following command:

$ sudo apt-get install mysql-server

After the installation is complete, you can start the MySQL service through the following command:

$ sudo service mysql start

2. Shutdown of MySQL

There are also two ways to shut down MySQL, one is to use the command line to shut down, the other is to use the service to shut down.

1. Use the command line to shut down

Enter the following command on the command line to shut down MySQL:

$ sudo systemctl stop mysql

After successful shutdown, you can check the status of MySQL through the following command:

$ sudo systemctl status mysql

If the status is normal, "Active: inactive (dead)" will be output, indicating that MySQL has been successfully shut down.

2. Use service to shut down

Using service to shut down MySQL also requires installing the MySQL service. If the MySQL service has been installed, you can use the following command to shut down the MySQL service:

$ sudo service mysql stop

The above is the detailed content of How to start and shut down MySQL. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete