SurrealDB
SurrealDB Docs Logo

Enter a search query

Navigation
Table of Contents

Migrating from MySQL to SurrealDB

This page details some MySQL data types and their SurrealQL equivalents, followed by links to the Surreal Sync tool which allows data from MySQL to be automatically imported to SurrealDB.

Data types

The following chart shows MySQL data types along with the equivalent or near-equivalent SurrealQL data type for each.

MySQL Data TypeWire Protocol TypeSQL RepresentationSurrealDB MappingNotes
BOOLEAN/BOOLTiny0/1bool0=false, 1=true conversion
TINYINTTiny-128 to 127intConverted to 64-bit integer
SMALLINTShort-32768 to 32767intConverted to 64-bit integer
MEDIUMINTInt24-8388608 to 8388607intConverted to 64-bit integer
INT/INTEGERLong-2147483648 to 2147483647intConverted to 64-bit integer
BIGINTLongLong-9223372036854775808 to 9223372036854775807intDirect conversion
FLOATFloat3.14float (f64)Converted to double precision
DOUBLEDouble3.141592653589793float (f64)Direct conversion
DECIMAL/NUMERICNewDecimal123.45numberConverted to SurrealDB Number with precision
CHAR(n)String'text'stringFixed-length, padding removed
VARCHAR(n)VarString'text'stringVariable-length string
TEXTBlob'long text'stringText blob as string
TINYTEXTTinyBlob'short text'stringSmall text as string
MEDIUMTEXTMediumBlob'medium text'stringMedium text as string
LONGTEXTLongBlob'very long text'stringLarge text as string
BINARY(n)String0x48656c6c6fbytesFixed-length binary data
VARBINARY(n)VarString0x48656c6c6fbytesVariable-length binary data
BLOBBlob0x48656c6c6fbytesBinary large object
TINYBLOBTinyBlob0x48656c6c6fbytesSmall binary data
MEDIUMBLOBMediumBlob0x48656c6c6fbytesMedium binary data
LONGBLOBLongBlob0x48656c6c6fbytesLarge binary data
DATEDate'2024-01-15'datetimeConverted to datetime at midnight UTC
TIMETime'14:30:00'stringTime format as string (HH:MM:SS.microseconds)
DATETIMEDateTime'2024-01-15 14:30:00'datetimeConverted to UTC datetime
TIMESTAMPTimestamp'2024-01-15 14:30:00'datetimeTimezone-aware, converted to UTC
YEARYear2024intYear as integer
JSONJson'{"key": "value"}'objectParsed and converted recursively
GEOMETRYGeometryST_GeomFromText('POINT(1 2)')objectConverted to geometric object with coordinates
POINTGeometryPOINT(1.5, 2.5)objectConverted to {"x": 1.5, "y": 2.5} object
ENUMEnum'option1'stringEnum value as string, constraints lost
SETSet'value1,value2'arrayConverted to array of strings
BIT(n)Bitb'1010'stringBit string as binary string representation

Importing from MySQL using Surreal Sync

Surreal Sync can be used to exports MySQL tables to SurrealDB.

It supports inconsistent full syncs and consistent incremental syncs, and together provides ability to reproduce consistent snapshots from the source MySQL tables onto the target SurrealDB tables.

For more on how to import data from MySQL to SurrealDB, please see the following pages in the Surreal Sync repo.