Home > Database > Mysql Tutorial > body text

How to start and shut down MySQL

PHPz
Release: 2023-04-12 15:07:03
Original
1905 people have browsed it

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
Copy after login

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

$ sudo systemctl status mysql
Copy after login
Copy after login

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
Copy after login

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

$ sudo service mysql start
Copy after login

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
Copy after login

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

$ sudo systemctl status mysql
Copy after login
Copy after login

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
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template