Get the App
SLTechnology News&Howtos  ›  Database  › 

How to change the character set of a production MySQL database table

Shulou Source: shulou.com Published: 2022-06-01 13:31:47 09月30日 Update

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

Tags: Data time structure database notes memos learning experiments updates characters character sets production Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi OPPO Reno NVidia Xiaomi Shulou Information