How to change the character set of a production MySQL database table
In the past, when I was studying mysql, I saw the notes of the experiment when I was sorting out them today, so I wrote down the memos.
1. Export the table structure
Mysqldump-uroot-predhat12345-S / data/3306/mysql.sock-- default-character-set=latin1-d kitty > kittytable.sql
Description:-d only guide table structure
2. Edit kittytable.sql and change lantin1 to utf8
Can be modified in batches with sed
3. Make sure that the database is no longer updated and export all data
Mysqldump-uroot-predhat12345-S / data/3306/mysql.sock-- quick-- no-create-info-- extended-insert-- default-character-set=latin1 kitty > kittydata.sql
4. Open kittydata.sql and change set names latin1 to set names utf8
5. Delete the original database tables and data (need to be cautious)
6. Build a database
Create database kitty default charset utf8
7. Create tables and execute kittytable.sql
Mysql-uroot-predhat12345-S / data/3306/mysql.sock kitty