utf8 garbled when importing into mysql

I think it might have something to do with collation as well, but I’m not sure. In my case it certainly did, since I had to support cyrillic.
Try this, worked for me:

  1. Set initial collation while creating the target database to utf8_unicode_ci

  2. Add SET NAMES 'utf8' COLLATE 'utf8_unicode_ci'; to the top of your sql file

  3. Run mysql -u root -p --default-character-set=utf8 yourDB < yourSQLfile.sql

One more thing, in order to properly get the UTF-8 data form your database, you’ll have to modify your connection string as well. For example:

mysql.url=jdbc:mysql://localhost:3306/nbs?useJvmCharsetConverters=false&useDynamicCharsetInfo=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&useEncoding=true

Additionally, take a look at what my problem was.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)