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 realization method of mysql4.1 data conversion

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "the realization method of mysql4.1 data conversion". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the realization method of mysql4.1 data conversion".

Mysql 4.1adds coding support, so it's a little more troublesome to convert old data, but it's no problem as long as you pay attention to the following points:

1. Be sure to dump the original data before conversion. Generally speaking, the original data is encoded by gb2312. The dump command is as follows:

Mysqldump-u-p database-add-drop-table-extended-insert

-add-drop-table is to save table creation during import,-extended-insert is to prevent a sql statement from being too large during import, and think about how horrible it is for your thousands of records to be written in a sql statement.

It is assumed that the original database is gb2312 encoded and needs to be converted to utf8 encoding, and the conversion between other encodings is similar.

2, modify the dump out of the sql file, use Emeditor or iconv to convert the encoding of the file to utf-8, pay attention to the best do not want that "Unicode Signature (BOM)", because mysql.exe does not recognize. Then replace gbk_bin with utf8_general_ci in the file, replace gbk with utf8, and then add

Set names utf8

The errors that are not recognized by BOM,mysql are roughly as follows:

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the ma

Nual that corresponds to your MySQL server version for the right syntax to use n

Ear'?

/ *! 40101 SET @ OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT * /'at line 1

3. Rebuild the mysql library, and then import the backup sql statement. The import command is as follows:

Mysql-u-p database

< dumpdata.sql 4、如果是以前导出的文件,导入的时候遇到错误: Got a packet bigger than 'max_allowed_packet' bytes or ERROR 1153 (08S01) at line 616: Got a packet bigger than 'max_allowed_packet' by tes 就需要修改mysql的最大允许包大小了,编辑my.ini,在[mysqld]部分(不在这部分没用)添加一句: set-variable=max_allowed_packet=10485760 重启mysql服务就可以了,我这里设置的是大约10M。 到这里数据导入基本就完成了,接下来就是根据各个应用的不同来调整了,一般有的系统已经支持了,但还有的不支持,不过调整方法大概分以下几类: 1、在数据库连接后面加上 mysql_connect(…. mysql_query("set names 'utf8′"); 这种情况最多,比如Brim什么的。 2、将语言文件或模板文件的编码设置为utf-8,注意是直接把文件编码转换了就可以,内容不用管,这样的有phpwind, mantis。使用工具可以是iconv,在这里可以下载。 iconv -f gb2312 -t utf-8 gb2312.html >

Utf-8.html

3. Modify the template file and set the

Most of the systems that used to be gb2312 codes need to be changed.

Thank you for your reading, the above is the content of "the realization method of mysql4.1 data conversion". After the study of this article, I believe you have a deeper understanding of the realization method of mysql4.1 data conversion, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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