MySQL and encoding

Follow me for more content or contact for work opportunities:
Twitter / LinkedIn

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

Follow me for more content or contact for work opportunities:
Twitter / LinkedIn