To Export/Import MySQL database with correct character set on dedicated server export your database with the correct character set is important in order to avoid any kind of problems with data that has non english characters within the table.

For example, if the character set of your data is Unicode (UTF8) you can use the following command to export it using this character set:

The syntax for the command is as follows :

mysqldump -u UserName -p Password –default-character-set=utf8 User_Database > backup.sql

Replace UserName, Password and User_Database with values for your database and you will have a file named “backup.sql” encoded in UTF-8.

When you import a database backup into an empty MySQL database tables then you can set the exact character set for the data. For that use the following syntax for the command which is as follows,

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 inserted data is properly managed and inserted correctly.

Leave a Reply