Home  >  Article  >  Database  >  How to start and shut down MySQL

How to start and shut down MySQL

PHPz
PHPzOriginal
2023-04-12 15:06:281748browse

MySQL is currently one of the most popular relational databases. Whether it is developing a website or operating an enterprise-level business system, MySQL is one of the essential components.

In the Linux system, starting and shutting down MySQL requires mastering some basic knowledge and skills. Here is an introduction to how to start and shut down MySQL.

1. Starting MySQL

There are two ways to start MySQL, one is to use the command line to start, 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 the MySQL service to be installed. If the MySQL service has been installed, you can use the following command to shut down the MySQL service:

$ sudo service mysql stop

3. Summary

MySQL is a very important component. For developers and administrators, it is very necessary to learn how to start and shut down MySQL.

The above is a basic introduction to the startup and shutdown of MySQL. I hope you can master these skills and better manage and use MySQL.

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:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn