Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14120 reviews 1680 hosting providers

Questions & Answers

How to import/export MySQL database with exact character set on my Dedicated server?

Mar 19, 2012 by Dan_31
Hi friends,

does anyone know how can I import/export MySQL database with exact character set on my dedicated server?

1 Answer

0 votes
Mar 19, 2012 by RalphK
Hi Dan

If the character set of your data is Unicode (UTF8) you can use the following command to export it using this charset:

mysqldump -uUSERNAME -pPASSWORD --default-character-set=utf8 USER_DATABASE > backup.sql

Replace USERNAME, PASSWORD and USER_DATABASE with the appropriate values for your database and you will have a file named "backup.sql" properly encoded in UTF-8.

When you import backup into an empty MySQL database, you can set the exact character set for the data that will be inserted. To do this, use the following command:

mysql -uUSERNAME -pPASSWORD --default-character-set=utf8 USER_DATABASE < backup.sql

Replace --default-character-set=utf8 with the charset used for the creation of the backup.sql file. This will ensure that your data is inserted correctly.