12

I just checked my MySQL tables and I have default set as latin1. Is that generally the default?

How can I make it explicit for all my tables that I want the database to be utf-8?

I know there is a db configuration that can change the default, but I think there is also a way to do it per-migration. How could I permanently set my rails migrations from now on to be utf-8?

Thanks!

GeekedOut
  • 16,905
  • 37
  • 107
  • 185

1 Answers1

21

create_table(:table_name, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8')

Olivier L.
  • 2,575
  • 1
  • 17
  • 11
  • 1
    Alternatively, you can set `default-storage-engine = InnoDB` in your my.cnf for MySQL. You can also set MySQL's default character set and collation to utf8. There are a lot of options here, so you'll want to dive into the docs for more info on that: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html – xentek Sep 16 '11 at 15:36