MySQL and encoding

You can connect with me on LinkedIn to discuss collaborations and work opportunities.

You can also follow me on Twitter, Bluesky and Mastodon.

Today I had another encoding problem in my life...

I had a file with sql inserts, encoded with utf-8. My unix terminal, also encoded with utf-8. I had a database as well, and both database and tables encoded with utf-8.

My problem: when executing my sql file to my database, the data encoding was corrupted. There were just one missing piece not encoded with utf-8, MySQL terminal.

To fix it: mysql -u myuser --default_character_set utf8 mydatabase < myfile

You can connect with me on LinkedIn to discuss collaborations and work opportunities.

You can also follow me on Twitter, Bluesky and Mastodon.