diff --git a/README.md b/README.md index 77fd29ec..564dbb75 100644 --- a/README.md +++ b/README.md @@ -273,7 +273,7 @@ Mysql2::Client.new( :database, :socket = '/path/to/mysql.sock', :flags = REMEMBER_OPTIONS | LONG_PASSWORD | LONG_FLAG | TRANSACTIONS | PROTOCOL_41 | SECURE_CONNECTION | MULTI_STATEMENTS, - :encoding = 'utf8', + :encoding = 'utf8mb4', :read_timeout = seconds, :write_timeout = seconds, :connect_timeout = seconds, @@ -367,7 +367,7 @@ Use the value `mysql2` as the adapter name. For example: ``` yaml development: adapter: mysql2 - encoding: utf8 + encoding: utf8mb4 database: my_db_name username: root password: my_password diff --git a/lib/mysql2/client.rb b/lib/mysql2/client.rb index 9811835e..2bb81a87 100644 --- a/lib/mysql2/client.rb +++ b/lib/mysql2/client.rb @@ -45,8 +45,8 @@ def initialize(opts = {}) end end - # force the encoding to utf8 - self.charset_name = opts[:encoding] || 'utf8' + # force the encoding to utf8mb4 + self.charset_name = opts[:encoding] || 'utf8mb4' mode = parse_ssl_mode(opts[:ssl_mode]) if opts[:ssl_mode] if (mode == SSL_MODE_VERIFY_CA || mode == SSL_MODE_VERIFY_IDENTITY) && !opts[:sslca]