Is it possible to convert SQLite to MySQL “as is”?

Probably the quick and easiest way to convert SQLite to MySQL includes two general steps:

  • Export SQLite database to dump file using SQLite .dump command.
1
sqlite3 sample.db .dump > dump.sql
  • You can then (in theory) import SQLite dump into the MySQL database.
1
mysql -p -u root -h 127.0.0.1 test < dump.sql

“In theory” means that solution wouldn’t work as there are a few differences in grammars between MySQL and SQLite.

There are just some differences between SQLite and MySQL syntax

SQLite MySQL
AUTOINCREMENT AUTO_INCREMENT
TEXT varchars
double quotes (" “) backticks (` `)
BEGIN TRANSACTION; COMMIT; BEGIN; COMMIT
CLOB TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT
PRAGMA foreign_keys=OFF; SET FOREIGN_KEY_CHECKS=0;