I'm using Rails 5 and MySQL 5.7. I have the following in my database.yml:
default: &default
adapter: mysql2
pool: 5
encoding: utf8mb4
charset: utf8mb4
collation: utf8mb4_unicode_ci
socket: /tmp/mysql.sock
development:
<<: *default
database: [...]
username: [...]
password: [...]
I run rake db:reset to recreate my database and I run show create table users and I see CREATE TABLEusers([...]) ENGINE=InnoDB DEFAULT CHARSET=utf8.
Why does my CHARSET=utf8 and how can I fix it (make it equal utf8mb4)? Thanks.
rake db:reset is wrong. rake db:drop && rake db:create && rake db:migrate is correct.
The reset just created the tables from the already stored schema which had the wrong charset and collation. But re-creating them from the migrations created them with the new charset and collation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With