1. 程式人生 > >修改mysql資料表字符集

修改mysql資料表字符集

修改資料庫

檢視當前資料庫字符集

show VARIABLES like 'character%';

修改資料庫字符集

alter database 資料庫名 character set utf8;

ps:修改完資料庫字符集,需要重啟mysql資料庫。


修改表

單條SQL:

ALTER TABLE `cmf_third_party_user` CONVERT TO CHARACTER SET UTF8;

多條SQL:在後面加英文 ';' 號

ALTER TABLE `cmf_third_party_user` CONVERT TO CHARACTER SET UTF8;
ALTER TABLE `cmf_user` CONVERT TO CHARACTER SET UTF8;
ALTER TABLE `cmf_user_action` CONVERT TO CHARACTER SET UTF8;
ALTER TABLE `cmf_user_action_log` CONVERT TO CHARACTER SET UTF8;
ALTER TABLE `cmf_user_balance_log` CONVERT TO CHARACTER SET UTF8;
ALTER TABLE `cmf_user_favorite` CONVERT TO CHARACTER SET UTF8;
ALTER TABLE `cmf_user_login_attempt` CONVERT TO CHARACTER SET UTF8;
ALTER TABLE `cmf_user_score_log` CONVERT TO CHARACTER SET UTF8;
ALTER TABLE `cmf_user_token` CONVERT TO CHARACTER SET UTF8;

ALTER TABLE `cmf_verification_code` CONVERT TO CHARACTER SET UTF8;