Skip to main content

Load Data from MySQL

Using mysqldump to load data from MySQL into Databend.

Before you begin

  • Install MySQL client and mysqldump
  • Databend: You will connect to the database and table using MySQL client, see How to deploy Databend.

Step 1. Dump MySQL table schema and data to file

Dump book_db.books table schema and datas
mysqldump --single-transaction --compact -uroot -proot book_db books > dumpbooks.sql
tip

mysqldump Options: --single-transaction --compact

The dumpbooks.sql looks like:

dumpbooks.sql
CREATE TABLE `books` (
title varchar(255),
author varchar(255),
date varchar(255)
);
INSERT INTO `books` VALUES ('Transaction Processing','Jim Gray','1992'),('Readings in Database Systems','Michael Stonebraker','2004');
... [snip] ...
INSERT INTO `books` VALUES ('Transaction Processing','Jim Gray','1992'),('Readings in Database Systems','Michael Stonebraker','2004');

Step 2. Load Data into Databend from the sql File

mysql -uroot -h127.0.0.1 -proot -P3307 < dumpbook.sql

All tables and data from users will now be loaded into Databend.

Step 3. Verify the Loaded Data

mysql>
select * from books;
+------------------------------+----------------------+-------+
| title | author | date |
+------------------------------+----------------------+-------+
| Transaction Processing | Jim Gray | 1992 |
| Readings in Database Systems | Michael Stonebraker | 2004 |
+------------------------------+----------------------+-------+

Step 4. Congratulations!

You have successfully completed the tutorial.