This article will introduce you to the common commands of MySQL in detail. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/202106/18/2021061809193986819.jpg)
1. Start and stop the MySQL service
(Right-click to open the command prompt in administrator mode)
输入命令:net start mysql 来启动服务
Copy after login
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/000/000/062/947a4a816f25fbea36fcfe6a37f31796-0.png)
输入命令:net stop mysql 来关闭服务
Copy after login
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/000/000/062/947a4a816f25fbea36fcfe6a37f31796-1.png)
2. MySQL login and exit
2.0 MySQL parameters
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/000/000/062/8011d78f99624a0477bad24d2f266997-2.png)
##2.1 MySQL login
输入命令参数:mysql -u root -p
Copy after login
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/000/000/062/8011d78f99624a0477bad24d2f266997-3.png)
2.2 MySQL exit
Input parameters:
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/000/000/062/8011d78f99624a0477bad24d2f266997-4.png)
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/000/000/062/8011d78f99624a0477bad24d2f266997-5.png)
3. Modify the MySQL prompt
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/000/000/062/04e2cdfff1fa3671136fe0a7035a2275-6.png)
Method 1: Specify via parameters when connecting to the client
After we log in to MySQL, the original prompt should be [ >mysql], we change it to [localhost] through the following command
命令行:mysql -uroot -proot --prompt -\h
Copy after login
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/000/000/062/04e2cdfff1fa3671136fe0a7035a2275-7.png)
Method 2: After connecting to the client, modify it through the prompt command
prompt mysql>
Copy after login
At this time, the prompt will change to [mysql>]
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/000/000/062/04e2cdfff1fa3671136fe0a7035a2275-8.png)
4. Common commands
1. Display the version of the current server
SELECT VERSION();
Copy after login
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/000/000/062/c597e5179cdc29d682929a0424e21781-9.png)
2. Display the current date and time
SELECT NOW();
Copy after login
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/000/000/062/c597e5179cdc29d682929a0424e21781-10.png)
3. Display the current user
SELECT USER();
Copy after login
![What are the commonly used commands in MySQL?](https://img.php.cn/upload/article/000/000/062/c597e5179cdc29d682929a0424e21781-11.png)
5. MySQL statement specifications
- [Keyword] and [Function] names are all in uppercase letters
- [Database] name , [Table] name, [Field] name all lowercase
- [SQL] statement must end with [;]
Related recommendations: "
mysql tutorial》
The above is the detailed content of What are the commonly used commands in MySQL?. For more information, please follow other related articles on the PHP Chinese website!