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

The method of modifying MySQL character set garbled and library character set

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

Share

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

The following mainly brings you to modify the MySQL character set garbled and library character set method, hope to modify the MySQL character set garbled and library character set method can bring you practical use, this is also my main purpose of editing this article. All right, don't talk too much nonsense, let's just read the following.

Unified character set ensures no garbled code: utf8 is recommended for both Chinese and English environments.

1.linux system language

/ etc/sysconfig/i18n

LANG= "zh_CN.utf8"

2.mysql client

Temporary:

Set names utf8

Permanent:

Profile my.cnf

[client]

Default-charater-set=utf8

3.mysql server

[mysqld]

Character-set-server=utf8

4.mysql database building table statement

Specified character set to build a database

Create database oldboy_utf8 default character set uft8 collate utf8_general_ci

Specified character set creation table

Create table student (

Id int (4) not null auto_increment

Name char (20) not null

Primary key (id)

) engine=inonodb auto_increment=10 default charset=utf8

5. The character set of the development program

Simulate the actual process of modifying the database of latin1 character set to GBK character set

1. Export table structure

Mysqldump-uroot-p-- default-character-set=latin1-d dbname > alltatale.sql

-- default-character-set=latin1 connects with latin1-d only table structure

two。 Edit alltable.sql to change latin1 to gbk

Sed replacement

3. Make sure the database is not being updated and export all data

Mysqldump-uroot-p-quick-no-create-info-extended-insert-default-character-set=latin1 dbname > alldata.sql

4. Open alldata.sql to modify set names latin1 to set names gbk; (or modify the server and client of the system)

5. Build a database

Create database dbname default charset bgk

6. Create tables and execute alltable.sql

Mysql-uroot-p dbname

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