Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report