In my Rails 4.2 app I stumbled on strange issue. I had to switch mysql encoding to utf8mb4 (to allow Emoji in posts). I've updated MySql to 5.7, altered tabels etc. Updated database.yml with:
encoding: utf8mb4
collation: utf8mb4_unicode_ci
Everything worked on my local machine that runs mac OS.
On test server I've done same steps and configuration. But if I set
encoding: utf8mb4
in database.yml I get
Mysql2::Error Can't initialize character set utf8mb4 (path: /usr/share/mysql/charsets/)
Additional MySQL setup for mysql I've done in my.cnf on both machines:
innodb_file_format = Barracuda
innodb_large_prefix
innodb_file_per_table = 1
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8mb4'
innodb_file_format_max = Barracuda
innodb_strict_mode = 1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
I can add emoji on test server but not through Rails app.
On both machines I'm usign mysql2
version 0.3.21
.
What can cause this issue?
PS. Even I don't have it on my local I've added utf8mb4 to Index.xml on test machine, but it didn't helped.
Maybe this will help: RoR:
application_controller.rb
: