Joyoyoyoyoyo
Joyoyoyoyoyo

Reputation: 165

Migrating SQL Server table to MySQL table with different encodings

I have a table in SQL server that I want to move to a MySQL table. However, I want to change the default encoding from latin-1 to utf-8. I've tried running the SQL Server Import and Export Wizard, which exports a csv to a file. It fails when I select a utf-8 encoding for the "Code page". It is stored as latin-1.

Anyway, I was wondering how I could export this data and import it into MySQL as utf-8? I do not want to open a text-editor and save the exported file as UTF-8.

Upvotes: 1

Views: 2194

Answers (1)

Rick James
Rick James

Reputation: 142258

Plan A:

Continue to export as SQL_Latin1_General_CP1_CI_AS, but be sure to set up the import as CHARACTER SET utf8.

However, this may tricky if the CREATE TABLE statements are buried in the dump. So...

Plan B:

Export and Import as currently being done. Then, for each table, do

ALTER TABLE tbl CONVERT TO CHARACTER SET utf8;

If you plan to handle Chinese, utf8mb4 would be better.
For many uses, the default COLLATE utf8_general_ci is fine, but you could consider utf8_unicode_ci.

Upvotes: 1

Related Questions