Source Insert
This document will guide you to use the source command to import data in batches to MatrixOne Intelligence.
Syntax Structure
SOURCE /path/to/your/sql_script.sql;
/path/to/your/sql_script.sql is the absolute path to the SQL script file. When executing this command, the client reads the specified SQL script file and executes all SQL statements contained therein.
Tutorial Example
In this tutorial, you will be guided on how to use the source command to migrate data from MySQL to MatrixOne Intelligence.
Steps
1. MySQL Data Dump
You need to have full access to your MySQL instance.
First, use mysqldump to dump the MySQL table structure and data into a file using the following command. If you are not familiar with how to use mysqldump, see mysqldump Tutorial.
mysqldump -h IP_ADDRESS -uUSERNAME -pPASSWORD -d DB_NAME1 DB_NAME2 ... OUTPUT_FILE_NAME.SQL
The following example is to use the command to dump all table structures and data in a database named test to a file named a.sql.
mysqldump -h 127.0.0.1 -uroot -proot -d test > a.sql
2. Import to MatrixOne Intelligence
Import the entire table structure and data into MatrixOne Intelligence.
-
Open the MySQL terminal and connect to MatrixOne Intelligence.
-
Create the database
testand enter the databasetest. -
Import the sql file into MatrixOne Intelligence through the
sourcecommand.
mysql> source /YOUR_PATH/a.sql
If the sql file is large, you can use the following command to run the import task in the background:
nohup mysql -h freetier-01.cn-hangzhou.cluster.matrixonecloud.cn -P 6001 -u 585b49fc_852b_4bd1_b6d1_d64bc1d8xxxx:admin:accountadmin -p'$pwd' -e 'use dbname; source /YOUR_PATH/a.sql;' &
3. Check the data
After the import is successful, use the following SQL statement to view the import results:
use test;
show tables;
select * from table_name;
Limitation Description
MatrixOne Intelligence already supports MySQL table creation statements, so it can smoothly migrate MySQL tables to MatrixOne Intelligence. However, it should be noted that during the migration process, some MySQL keywords are incompatible, such as engine=, etc., will be automatically ignored in MatrixOne Intelligence and will not affect the migration of table structure.