Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Today my database character set and collation is set to latin1. All of the tables in the database are however already set to DEFAULT CHARSET=utf8 and all data is utf8.

Is if it is safe to change character set and collation of the database to utf8?

Is it safe to also set the default settings in the my.cnf file with:

[client] default-character-set=utf8

[mysqld] default-character-set = utf8

A typical table in the database looks like this:

CREATE TABLE `tblpayment` (
    `paymentid` int(11) NOT NULL AUTO_INCREMENT,
    `userid` mediumint(9) DEFAULT NULL,
    `payed` enum('False','True') CHARACTER SET latin1 DEFAULT 'False',
    PRIMARY KEY (`paymentid`)
) ENGINE=InnoDB AUTO_INCREMENT=72803 DEFAULT CHARSET=utf8;

As you can see the enum "payed" is still using latin1 for some reason, however the rest of the table is utf8. Is it safe to change the CHARACTER SET of the enum to utf8 instead?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Setting the default character set and collation is completely safe. This will ensure that future DDL changes will use utf8, but will not affect existing columns that use latin1. Those will have to be converted to utf8. Make a backup of the data, because there are risks of data corruption (one example).

And for completeness, I will point out that adding the changes in the my.cnf will require a server restart.

share|improve this answer
    
Thanks! All data in the database is already converted (my tables where first created in latin1). But for some reason I must have forgotten about the enum('False','True') column. Is it safe to just switch these to utf8 too, without converting? –  Martin Feb 24 '12 at 8:06
    
@Martin sorry, I didn't see this. You should be able to set them to utf8, but just be ready with a backup (good practice)! –  Derek Downey Mar 2 '12 at 14:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.