Home  >  Article  >  Database  >  Detailed explanation of the source command in MySQL database

Detailed explanation of the source command in MySQL database

巴扎黑
巴扎黑Original
2017-08-11 15:21:402402browse

This article mainly introduces the detailed explanation and examples of the MySQL database source command. Friends who need it can refer to

The detailed explanation and examples of the MySQL database source command

MySQL database source command, which is a database import command. The usage of the source command is very simple. First, you need to enter the command line management interface of the MySQL database, then select the database to be imported, and execute the source command. As shown below.

MySql database source command


mysql> use test
 
Database changed
 
mysql> set names utf8;
 
Query OK, 0 rows affected (0.00 sec)
 
mysql> source C:/test.sql
 
Query OK, 0 rows affected (0.00 sec)
 
Query OK, 0 rows affected (0.33 sec)
 
Query OK, 0 rows affected (0.07 sec)
 
Query OK, 1 row affected (0.02 sec)
 
Query OK, 1 row affected (0.03 sec)
 
Query OK, 1 row affected (0.02 sec)
 
mysql> set names gbk;
 
Query OK, 0 rows affected (0.00 sec)

Tips:

1. In Windows, the file path should use "/" to replace the default path character "\", such as:


mysql> source C:/test.sql

2. Make sure the character encoding of the script file (.sql / .ddl) is utf8;

3. Before running the source command, execute the command: set names utf8;


mysql> set names utf8;
mysql> source C:/test.sql

4. If you need to correctly view Chinese on the command line after running the source command, first execute the command: set names gbk; modify the command line window character encoding. As follows:


mysql> set names gbk;
 
mysql> select * from user;

The above is the detailed content of Detailed explanation of the source command in MySQL database. 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