Home Rails Mysql Utf8mb4 Mysql2error Incorrect String Value Error
Post
Cancel

Rails Mysql Utf8mb4 Mysql2error Incorrect String Value Error

refer to:
https://stackoverflow.com/questions/22464011/mysql2error-incorrect-string-value

1. change your  database.yml:

development:
  adapter: mysql2
  database: db
  username:
  password:
  encoding: utf8mb4
  collation: utf8mb4_unicode_ci

2.run this SQL ( change YOUR_XX_NAME )

ALTER TABLE `YOUR_TABLE_NAME`
  CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
MODIFY YOUR_COLUMN_NAME VARCHAR(250)
    CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
This post is licensed under CC BY 4.0 by the author.