Thursday 15 November 2012

Import a UTF-8 SQL file into MySQL Server

importing a SQLFile into MySQL works only if the .sql file itself is encoded with default (ISO-????) character set. But if you have file with UTF-8 encoding, it won't work. Saving the file in UTF-8 encoding will not work as well, since mysql doesn't know which encoding is enabled and interprets it as default encoding. Using this command will tell to MySQL to use UTF-8 encoding while importing the Data:

>> mysql -h host -u username -ppassword --default_character_set=utf8 database < myfile.sql

No comments:

Post a Comment