Prerequisites
- MySQL database (5.7 or 8.0)
- Access to MySQL server with sufficient privileges
- Xata account and project setup
- Network access to your MySQL server
Install and Configure the Xata CLI
Install the Xata CLI:Important Note
Xata is built on PostgreSQL, so migrating from MySQL requires:- Schema conversion from MySQL to PostgreSQL
- Data export/import using mysqldump
- Manual verification of data types and constraints
Create Migration User
Connect to your MySQL database and create a dedicated user for migration:Export MySQL Schema
First, export your MySQL schema to understand the structure:Schema Conversion
Common MySQL to PostgreSQL Conversions
You’ll need to convert your MySQL schema to PostgreSQL format:Data Types
Auto Increment
Indexes
Foreign Keys
Export Data
Export your MySQL data in a PostgreSQL-compatible format:Initialize Xata Project
Set up your Xata project configuration:Create PostgreSQL Schema
Create the converted schema in Xata:Import Data
Import your converted data into Xata:Alternative: Using pgloader
For more automated conversion, you can usepgloader
:
Verification
After migration, verify your data:-
Connect to Xata Branch:
-
Check Data Integrity:
- Test Application: Verify your application works with the new PostgreSQL schema
Common Conversion Issues
1. Date/Time Handling
MySQL and PostgreSQL handle dates differently:2. String Functions
Some string functions differ:3. JSON Handling
4. Auto Increment Sequences
After importing, reset sequences:Next Steps
- Explore Xata branching for development workflows
- Learn about schema changes with zero downtime
- Set up continuous sync for ongoing replication
- Consider deployment options for your Xata instance