I have a db with content like
https://pastebin.com/LRgTqHjN
(stored with the wrong encoding)
Save it to a file record.sql
mysql -u root --password=root enctest < record.sql
get the same garbage as input;
mysqldump -u root --password=root enctest
but if you add;
mysqldump -u root --password=root --default-character-set=latin1 enctest
it shows the correct content.
I want to reproduce the latter behaviour in C#, I use the following code:
"MySqlConnection": "server=localhost;port=3306;database=enctest;user=root;password=root",
and
MySqlCommand cmd = new MySqlCommand($"select * from siteTxt", conn);
using (MySqlDataReader reader = (MySqlDataReader)(await cmd.ExecuteReaderAsync()))
{
for (int i=0;i<6;i++)
{
row.Add(reader.GetString(i));
}
}
But that shows the same garbage as:
mysqldump -u root --password=root enctest
How can I make it show the same output as the second mysqldump?
Note: the real table is a few terabytes in size; I cannot just dump it and reimport it (which would fix the issue) which is why I need to fix it in the C# reader.
Update: for viewing, a solution that works is to change the select query to:
CONVERT(BINARY(CONVERT({column}
USING latin1)) USING utf8mb4)
per string type column which obviously is less than ideal, but it works well.