Change mysql database character set to utf8
- Step 1: Change for all tables:
mysql --database=__DBNAME__ -B -N -e "SHOW TABLES" | awk '{print "SET foreign_key_checks = 0; ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; SET foreign_key_checks = 1; "}' | mysql --database=__DBNAME__
- Step 2: Change for database itself:
# mysql -u root
mysql> ALTER DATABASE tips CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)