MySQL to Tacnode Migration Guide

This guide provides a comprehensive, step-by-step process for migrating your data and applications from MySQL to Tacnode. It covers environment setup, permissions, data type mapping, SQL syntax differences, migration steps, application adaptation, best practices, and troubleshooting. All content is rewritten in native English for clarity and usability.

Overview

Tacnode offers distributed, relational, and semi-structured data capabilities. Migrating from MySQL requires careful planning, schema adaptation, and application refactoring.

Preparation

Environment Requirements

  • MySQL 5.6 or newer
  • Tacnode database instance (admin access)
  • Network connectivity between source and target (preferably private network)
  • Data migration tool (Tacnode Data Sync, ETL, or custom scripts)

Permission Setup

Create a dedicated MySQL user for migration:

CREATE USER 'tacnode_migration'@'%' IDENTIFIED BY 'your_password';
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'tacnode_migration'@'%';
FLUSH PRIVILEGES;

Create a target user in Tacnode:

CREATE USER tacnode_migration WITH PASSWORD 'secure_password';
GRANT ALL PRIVILEGES ON DATABASE ecommerce TO tacnode_migration;

Network Configuration

  • Ensure Tacnode can reach MySQL (configure firewall/security groups).
  • For public access, whitelist IPs and use secure connections.

Data Type Mapping

MySQL TypeTacnode TypeNotes
TINYINTSMALLINTRange differs
BOOL/BOOLEANBOOLEANTRUE/FALSE
MEDIUMINTINTEGERUse INTEGER
INT/INTEGERINTEGERCompatible
BIGINTBIGINTCompatible
FLOATREALPrecision may differ
DOUBLEDOUBLE PRECISIONCompatible
DECIMAL(p,s)NUMERIC(p,s)Compatible
DATEDATECompatible
DATETIMETIMESTAMPTacnode supports time zones
YEARSMALLINT/INTEGERUse integer
CHAR/VARCHARCHAR/VARCHARCompatible
TEXT typesTEXTUse TEXT
BLOB typesBYTEAUse BYTEA
ENUMVARCHAR + CHECKUse CHECK constraint
SETARRAY or tableUse ARRAY or related table
JSONJSONBUse JSONB

SQL Syntax Differences

FeatureMySQL SyntaxTacnode Syntax
Identifiersbackticks"double quotes"
Strings'single quotes''single quotes'
PaginationLIMIT offset, countOFFSET offset LIMIT count
NULL checksIS NULL/IS NOT NULLIS NULL/IS NOT NULL
String concatCONCAT()`
GROUP BYImplicit groupingExplicit grouping required
UNIONImplicit type conversionExplicit type conversion

Migration Steps

1. Assess and Prepare

  • Check MySQL database size and table structures:
    SELECT table_schema AS "Database", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" FROM information_schema.tables GROUP BY table_schema;
    SHOW CREATE TABLE users;
    SHOW CREATE TABLE orders;
  • Create databases and users in Tacnode:
    CREATE DATABASE ecommerce;
    CREATE USER tacnode_migration WITH PASSWORD 'secure_password';
    GRANT ALL PRIVILEGES ON DATABASE ecommerce TO tacnode_migration;

2. Schema Migration

  • Convert MySQL table definitions to Tacnode:
    -- MySQL
    CREATE TABLE users (
      id INT AUTO_INCREMENT PRIMARY KEY,
      username VARCHAR(50) NOT NULL,
      email VARCHAR(100) NOT NULL,
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    );
    -- Tacnode
    CREATE TABLE users (
      id SERIAL PRIMARY KEY,
      username VARCHAR(50) NOT NULL,
      email VARCHAR(100) NOT NULL,
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    );
  • Handle ENUM types:
    -- MySQL
    CREATE TABLE order_status (
      id INT AUTO_INCREMENT PRIMARY KEY,
      status ENUM('pending', 'processing', 'shipped', 'delivered') NOT NULL
    );
    -- Tacnode
    CREATE TABLE order_status (
      id SERIAL PRIMARY KEY,
      status VARCHAR(20) NOT NULL CHECK (status IN ('pending', 'processing', 'shipped', 'delivered'))
    );

3. Data Migration

  • Use Tacnode Data Sync, ETL, or custom scripts to transfer data.
  • Validate row counts and sample data:
    SELECT COUNT(*) FROM users;
    SELECT COUNT(*) FROM orders;
    SELECT * FROM users LIMIT 10;
    SELECT * FROM orders WHERE created_at >= CURRENT_DATE - INTERVAL '7 days';

4. Application Adaptation

  • Update connection strings:
    # MySQL
    jdbc:mysql://mysql-host:3306/ecommerce
    # Tacnode
    jdbc:postgresql://tacnode-host:5432/ecommerce
  • Adjust SQL syntax for pagination, NULL checks, string concatenation, etc.
  • Example: Pagination
    // MySQL
    String mysqlQuery = "SELECT * FROM users LIMIT 20, 10";
    // Tacnode
    String tacnodeQuery = "SELECT * FROM users OFFSET 20 LIMIT 10";

5. Testing and Validation

  • Functional tests:
    SELECT u.username, COUNT(o.id) AS order_count FROM users u LEFT JOIN orders o ON u.id = o.user_id GROUP BY u.username;
    SELECT DATE_TRUNC('month', created_at) AS month, COUNT(*) AS user_count FROM users GROUP BY DATE_TRUNC('month', created_at) ORDER BY month;
  • Performance tests:
    EXPLAIN ANALYZE SELECT * FROM orders WHERE user_id = 12345 AND created_at >= '2024-01-01';

Best Practices

Pre-Migration

  • Assess data volume, special types, and application dependencies.
  • Plan migration windows and rollback strategies.
  • Train your team on Tacnode.

During Migration

  • Migrate non-critical data first, then core business data.
  • Monitor migration progress and validate data consistency.
  • Document issues and solutions.

Post-Migration

  • Optimize indexes and storage post-migration.
  • Harden security (IP whitelist, user permissions, audit logs).

Troubleshooting

Data Type Incompatibility

  • Use CHECK constraints or application-level validation.

SQL Syntax Differences

  • Adapt queries or use ORM frameworks.

Collation/Charset Issues

  • Specify collation in Tacnode:
    CREATE TABLE my_table (name VARCHAR(100) COLLATE "en_US.utf8");