How to change character_set_database value in MySQL?

UPDATED: 03 September 2014
character_set_database + MySQL

MySQL is highly configurable database. It support different character set at Database level, Table level and Column level as well. Sometime it gets worse when you provide so many options.

We were facing an issue because of mixed character set at different level in MySQL. I've tried to change configuration [my.cnf in Linux and my.ini in Windows] file of MySQL but didn't work. I've searched to change value of 'character_set_database' but no one explained to the point. After many try and error I figured out solution.

How to check database character set in MySQL?
Execute following query to know the character set of current database. Currently its 'latin1'.
SHOW VARIABLES LIKE '%character_set_database%';
Variable_name value Value
character_set_database latin1


How to change database character set in MySQL?
We need to alter the database with new character set. We will change it to 'utf8', change character set as per your requirement.
ALTER DATABASE inventory CHARACTER SET utf8;
Now lets check the character set again by executing same query.
SHOW VARIABLES LIKE '%character_set_database%';
Variable_name value Value
character_set_database utf8

0 comments :