×
Community Blog Heterogeneous Database Migration: SQLite -> PolarDB for MySQL

Heterogeneous Database Migration: SQLite -> PolarDB for MySQL

This article describes how to use Navicat Premium to migrate SQLite databases to PolarDB for MySQL.

Background

There are many ways to migrate SQLite to MySQL databases in the industry, but most of them are offline. These different methods come down to the following three steps:

  1. Export data
  2. Convert data and structure
  3. Import MySQL data

If you use SQLite native commands to export data as a .sql file, you need to convert the structure and check the compatibility.

The following examples show the differences in data types between SQLite and MySQL:

INTEGER -> INT

AUTOINCREMENT -> AUTO_INCREMENT

When INTEGER(0/1) indicates boolean -> TINYINT(1)

If you want to avoid manual structure conversion and compatibility issues, the following describes detailed procedures for using Navicat Premium to migrate SQLite databases to PolarDB for MySQL.

Official website link of Navicat Premium: https://www.navicat.com/en/

1. Export SQLite Files

1.1 View the database file that SQLite needs to export.

.database

1

1.2 Locate the file in the system and download it to the local.

2

1.3 Use Navicat Premium to create an SQLite connection and import the .db file.

3
4

1.4 View the connected SQLite database and table file data.

5

1.5 Export the table in the SQLite database as a CSV file.

-----> Do not export it directly as an SQL file here.

6
7

For the exported CSV file, you can impose some custom restrictions, as follows (you can directly use the default settings).

8
9
10

2. Import Data to PolarDB for MySQL

2.1 Purchase a PolarDB for MySQL cluster instance.

2.2 Create a PolarDB connection account.

11

2.3 Enable the IP address whitelist for the cluster.

12

2.4 Enable the public endpoint.

13

2.5 Use Navicat or Alibaba Cloud Data Management Service (DMS) to connect to PolarDB for MySQL.

14
15

2.6 Create a database and import data.

16
17

Select the CSV file to import.

18

2.7 Select the CSV file exported by SQLite and import it into the database created by MySQL.

19
20
21

If you use Navicat throughout the operation, the settings here must be the same as those when you export the CSV file.

22

Here, the field length and primary key need to be modified according to the actual content.

23
24
25

2.8 View the imported table data.

26

The above is the steps to import data from SQLite to MySQL.

3. Check Data Consistency

The data is imported offline, not migrated online by using a tool. Therefore, data consistency must be checked. The following methods can help you check data consistency:

3.1 View the original SQLite database table and the count of data rows.

27
28
29

3.2 Check the exported CSV file to see whether the data and file encoding are normal.

30
31

3.3 Check the database table and the count of rows imported into PolarDB for MySQL.

32
33

0 0 0
Share on

ApsaraDB

424 posts | 90 followers

You may also like

Comments

ApsaraDB

424 posts | 90 followers

Related Products