Linux VPS7 min read•Last updated: •By SkyRain Cloud Team

How to Export and Import a MySQL Database Without Breaking Characters

Moving a website to a new server, cloning production into staging or taking a manual backup all require you to export and import a MySQL database. The commands are short, but one detail breaks more migrations than any other: character sets. Get them wrong and Hindi, Tamil or Bengali text turns into strings like नमसà¥à¤¤à¥‡, emoji become question marks, and you may not notice until customers do.

This guide gives the reliable command-line method with mysqldump, the settings that keep text intact, how to handle large databases and live sites, and how to copy a database straight from one server to another.

Quick answer

Export with mysqldump --single-transaction --default-character-set=utf8mb4 --routines --triggers --events dbname | gzip > dbname.sql.gz. On the new server, create the database with CHARACTER SET utf8mb4, then import with gunzip < dbname.sql.gz | mysql --default-character-set=utf8mb4 dbname. Using utf8mb4 on both sides keeps Indian-language text and emoji intact. For large databases, compress the dump, show progress with pv, and consider piping directly between servers over SSH.

Why character sets break migrations

MySQL stores text in a character set. Modern applications use utf8mb4, which covers every Unicode character, including Devanagari and other Indian scripts as well as emoji. MySQL's older utf8 (an alias for utf8mb3) cannot store characters that need four bytes, such as emoji, and the much older latin1 default cannot store Indian scripts correctly at all.

Corruption usually happens in one of two ways:

  • Double encoding: the dump is written or read with the wrong client character set, so UTF-8 bytes are converted again. The result is the familiar à or ठgibberish.
  • Truncation: four-byte characters are imported into a utf8mb3 column and replaced or cut off.

Both are prevented by being explicit about utf8mb4 when you export, when you create the database and when you import.

Export and import a MySQL database – SkyRain Cloud servers in India

Step 1: Check the source database

SELECT default_character_set_name, default_collation_name
  FROM information_schema.SCHEMATA WHERE schema_name = 'shopdb';

SELECT table_name, table_collation
  FROM information_schema.TABLES WHERE table_schema = 'shopdb';

If tables already use utf8mb4, the steps below keep them that way. If some use latin1 but contain UTF-8 text (common on very old sites), fix them in a planned conversion after the move rather than mid-migration.

Step 2: Export and import a MySQL database, part one: mysqldump

mysqldump -u root -p \
  --single-transaction --quick \
  --default-character-set=utf8mb4 \
  --routines --triggers --events \
  shopdb | gzip > shopdb-2026-11-23.sql.gz
OptionWhy use it
--single-transactionConsistent snapshot of InnoDB tables without locking the live site
--quickStreams rows instead of loading whole tables into memory
--default-character-set=utf8mb4Writes text without re-encoding it
--routines --triggers --eventsIncludes stored procedures, triggers and scheduled events, which are easy to forget
| gzipText dumps compress very well, often to a fraction of the original size

The full option list is in MySQL's mysqldump reference. Use an account with enough privileges; on Ubuntu, sudo mysqldump works through socket authentication, as explained in our MySQL root password guide.

Step 3: Create the database and import

On the destination server, create an empty database with the right defaults. Use utf8mb4_0900_ai_ci on MySQL 8, or utf8mb4_unicode_ci on MariaDB and older MySQL:

CREATE DATABASE shopdb CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
CREATE USER 'shopapp'@'localhost' IDENTIFIED BY 'a-long-random-password';
GRANT ALL PRIVILEGES ON shopdb.* TO 'shopapp'@'localhost';

Then import, with a progress bar if pv is installed:

pv shopdb-2026-11-23.sql.gz | gunzip | mysql -u root -p --default-character-set=utf8mb4 shopdb

Without pv, use gunzip < shopdb-2026-11-23.sql.gz | mysql ....

Copying straight from one server to another

For a server move, you can skip the intermediate file and stream the database over SSH:

mysqldump --single-transaction --quick --default-character-set=utf8mb4 \
  --routines --triggers --events shopdb \
  | gzip | ssh user@new-server "gunzip | mysql --default-character-set=utf8mb4 shopdb"

This works well for databases of a few gigabytes. For larger ones, tools that dump and load tables in parallel (such as mydumper/myloader) or physical backups are faster. For a whole-site move with minimal downtime, follow our zero-downtime migration checklist.

Step 4: Verify the import

  1. Compare row counts for important tables on both servers: SELECT COUNT(*) FROM orders;
  2. Check text in a non-English record, for example a product name in Hindi, in both the database and the website.
  3. Confirm the connection character set in your application: WordPress uses DB_CHARSET = utf8mb4 in wp-config.php; Laravel sets charset in config/database.php.
  4. Test logins, checkout and search before switching DNS.

Keep the dump file for a few days after the move, stored somewhere other than the new server. If a problem appears later, it is your quickest way to compare old and new data.

Common import errors and fixes

Error or symptomCauseFix
Gibberish such as न in Indian textCharacter set mismatch, causing double encodingRe-export and import with --default-character-set=utf8mb4 on both sides
Unknown collation utf8mb4_0900_ai_ciDump from MySQL 8 imported into MariaDB or MySQL 5.7Replace it with utf8mb4_unicode_ci in the dump before importing
Access denied; you need SUPER privilegeDEFINER clauses for users that do not exist on the new serverCreate those users, or edit the DEFINER clauses
MySQL server has gone awayVery large rows exceed max_allowed_packetRaise max_allowed_packet on the server and client
Import is very slowSlow disk or a small buffer poolImport on NVMe storage; see optimising an Ubuntu VPS

Why developers choose SkyRain Cloud VPS

Database moves are quicker on fast storage. SkyRain Cloud Intel VPS plans include:

  • KVM virtualization. Your own kernel and allocated vCores, so you can tune the system the way this guide describes.
  • Intel Xeon Platinum 8269CY hosts. Server-class Cascade Lake CPUs with DDR4 ECC memory.
  • NVMe SSD storage on every plan, which keeps I/O wait low for databases and builds.
  • Full root access to install and configure whatever your stack needs.
  • Unmetered 1 Gbps port in India, close to your users.
  • Simple billing and real support. Monthly billing in rupees with UPI, plus 24/7 tickets, WhatsApp and Discord.

Frequently Asked Questions

How do I export a MySQL database from the command line?
Run mysqldump --single-transaction --default-character-set=utf8mb4 --routines --triggers --events dbname | gzip > dbname.sql.gz.
How do I import a .sql.gz file into MySQL?
Create the database first, then run gunzip < dbname.sql.gz | mysql --default-character-set=utf8mb4 dbname.
Why is my Hindi text showing as strange characters after import?
The dump was exported or imported with the wrong character set, so the text was encoded twice. Re-export and import with utf8mb4 specified on both sides.
What is the difference between utf8 and utf8mb4 in MySQL?
MySQL's utf8 (utf8mb3) stores up to three bytes per character and cannot hold emoji. utf8mb4 supports all Unicode characters and is the recommended default.
Will mysqldump lock my live website?
Not for InnoDB tables when you use --single-transaction, which takes a consistent snapshot without blocking reads and writes.
How do I move a MySQL database directly to another server?
Pipe mysqldump through gzip and SSH into mysql on the new server, or use parallel tools such as mydumper for very large databases.

Conclusion

To export and import a MySQL database safely, be explicit about utf8mb4 at every step: when dumping, when creating the new database and when importing. Use --single-transaction to avoid locking a live site, include routines, triggers and events, compress the dump, and verify both row counts and real non-English text afterwards. Do that and your Hindi product names and customer emoji arrive exactly as they left.

For a fast home for your database in India, see our Intel VPS plans.

SkyRain Cloud Intel Xeon VPS Plans

KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.

PlanvCoresRAMStorageNetworkPriceGood forBuy
VPS 1 — Intel28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹649/monthBusiness websites, small apps, scheduled jobs and botsOrder
VPS 2 — Intel416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹1,169/monthBusiness software, mid-size databases, several sites on one serverCheck stock
VPS 3 — Intel832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹2,249/monthERP/CRM stacks, heavier databases, multiple production appsCheck stock
VPS 4 — Intel1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹4,299/monthHigh-memory workloads and consolidated production serversCheck stock

Prices are monthly in INR as listed on the SkyRain Cloud store (verified 2026-11-23). Live stock and final price are shown at checkout.

Instant UPI • ₹649/mo
Fast KVM Cloud Provisioning