1. Start the MySQL server
There are two ways to start the MySQL server: system server and command prompt (DOS).
Method 1: Start the MySQL server through the system server.
If MySQL is set as a Windows service, you can open the Windows Service Manager by selecting the "Start"/"Administrative Tools"/"Services" command. Find the mysql service in the server list, right-click it, and select the "Start" command in the pop-up shortcut menu to start the MySQL server.
Method 2: Start the MySQL server in the command prompt
Select the "Start"/"Run" command, enter the cmd command in the pop-up "Run" dialog box, and open the DOS window. Enter:
net start mysql
and press Enter to start the server.
Note: Although the method of opening the server is very simple, under normal circumstances, it is recommended not to stop MySQL, otherwise the database will not be usable.
2. Connect to the MySQL server
Click the start button, open cmd, find and enter the database installation folder, take mine as an example, mine is in mysql\ bin folder, the steps are as follows:
First find the database to see which disk it is installed on, enter it, and then find the installation folder. After finding it, enter mysql -uroot -proot to successfully connect to the database.
-u is followed by the user name of the database -p is followed by the password of the database
The specific operation results are as follows:
d: cd phpStudy\mysql\bin mysql -uroot -proot
At this point, we have connected Log in to the database
3. Disconnect the MySQL server
After connecting to the MySQL server, you can enter the exit or quit command at the MySQL prompt to disconnect the MySQL connection, as follows :
MySQL>quit;
4. Stop the server
There are three ways to stop the server:
The first one: stop through the system server
It’s the opposite of how we opened it. If MySQL is set up as a Windows service, you can open the Windows Service Manager by selecting the Start/Administrative Tools/Services command. Find the mysql service in the server list, right-click it, and select the "Stop" command in the pop-up shortcut menu to stop the MySQL server.
Second type: Stop at the command prompt
Open the DOS window and enter at the command prompt:
net stop mysql
Press Enter on a single machine MySQL server can be stopped.
Third method: Use the mysqladmin command to stop
Open the DOS command window, enter:
mysqladmin -uroot shutdown -proot
and press Enter to stop the server.
The above is the detailed content of Start, connect, disconnect and stop the MySQL database. For more information, please follow other related articles on the PHP Chinese website!