Get the App
SLTechnology News&Howtos  ›  Database  › 

How to start and stop Mysql database by Linux

Shulou Source: shulou.com Published: 2022-05-31 18:44:10 11月29日 Update

This article mainly introduces "Linux how to start and stop Mysql database", in daily operation, I believe many people in Linux how to start and stop Mysql database problems have doubts, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation methods, hope to answer "Linux how to start and stop Mysql database" doubts helpful! Next, please follow the small series to learn together!

How to Start/Stop/Restart MySQL Database

1. Check the MySQL version

Method 1: Status;

Select version();

2. Mysql Start, Stop, Restart Common Commands

a. Starting mode

1. Start with service:

[root@localhost /]# service mysqld start (version 5.0 is mysqld)

[root@szxdb etc]# service mysql start (version 5.5.7 is mysql)

2. Start with mysqld script:

/etc/inint.d/mysqld start

3. Start with safe_mysqld:

safe_mysqld&

b) Stop

1. Start with service:

service mysqld stop

2. Start with mysqld script:

/etc/inint.d/mysqld stop

3、mysqladmin shutdown

c. Restart

1. Start with service:

service mysqld restart

service mysql restart (version 5.5.7 command)

2. Start with mysqld script:

/etc/init.d/mysqld restart

Second, connect MySQL:

Format: mysql -h host address-u user name-p user password

Example 1: Connect to MYSQL on the local machine

Find mysql installation directory, generally you can directly type the command mysql -uroot -p, prompt you to enter the password after carriage return, if just installed MYSQL, super user root is no password, so enter directly into MYSQL, MYSQL prompt is: mysql>

Connect to MySQL on a remote host

Assume that the IP of the remote host is 10.0.0.1, the username is root, and the password is 123. Type the following command:

mysql -h20.0.0.1 -uroot -p123

(Note: u and root can be added without spaces, and the same is true for others)

3. Exit MySQL command

exit (carriage return)

At this point, the study of "how to start and stop Mysql database in Linux" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Tags: Data database command password method version user learning host script more help prompt practical next no address commonly used prompt article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Technology NVidia Shulou Tech Info Xiaomi