Home Rails Mysql Utf8,utf8mb4:mysql2::error:incorrectstringvalueerror
Post
Cancel

Rails Mysql Utf8,utf8mb4:mysql2::error:incorrectstringvalueerror

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.