最近一项目,需要将 utf8 编码的数据库转为 utf8 (以前都是gb2312转utf8 :D )
方法如下:
Step 1:
执行:./mysqldump -uroot -p --default-character-set=utf8 --extended-insert=FALSE DBNAME > DBNAME_GB2312.sql
Step 2:
sed -e '/^--/d' -e '/^\/\*/d' -e '/^$/d' -e 's/utf8_bin/gb2312_bin/' -e 's/utf8/latin1或者gb2312/' DBNAME_GB2312.sql > CONV_DBNAME_GB2312.sql
Step 3:
执行:./mysql -uroot -p --default-character-set=utf8 DBNAME < CONV_DBNAME_GB2312.sql
方法如下:
Step 1:
执行:./mysqldump -uroot -p --default-character-set=utf8 --extended-insert=FALSE DBNAME > DBNAME_GB2312.sql
Step 2:
sed -e '/^--/d' -e '/^\/\*/d' -e '/^$/d' -e 's/utf8_bin/gb2312_bin/' -e 's/utf8/latin1或者gb2312/' DBNAME_GB2312.sql > CONV_DBNAME_GB2312.sql
Step 3:
执行:./mysql -uroot -p --default-character-set=utf8 DBNAME < CONV_DBNAME_GB2312.sql