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 coding problem and its solution when mysql associates two tables

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

When Mysql associates two tables, an error message Illegal mix of collations is generated

1. Use the tool to change the coding mode of the database and two tables

2. This step is very important, and you need to change the encoding of the field.

ALTER TABLE `Table name `CHANGE `dev_ chancode`` field `VARCHAR (32) CHARACTER SET gbk NOT NULL

Summary: we must pay attention to the unified coding method when building the table, and make it super troublesome in the follow-up.

How to solve the problem of MySQL table transcoding

Export the table structure of the data table to be exported (you can use Phpmyadmin, mysqldump, etc.), then change the CHARSET=latin1 of the exported create table statement to CHARSET=utf8, execute the create table statement in the target library newdbname to build the table structure, and then start exporting-importing data. Command:. / mysqldump-d DB_Dig > / usr/local/tmp/tables.sql command line: go to the mysql command line, and mysql-hlocalhost-uroot-paired commands * dbname execute SQL select * from tbname into outfile'/ usr/local/tbname.sql' To transcode tbname.sql to utf-8 format, it is recommended to use UltraEditor. You can directly use the editor's "convert-> ASCII to UTF-8 (Unicode Editing)", or save the file as UTF-8 (no BOM) and execute the statement set character_set_database=utf8 under the mysql command line. Note: set the environment variable of mysql so that when mysql reads the sql file next, it will interpret the contents of the file in the form of utf8 and execute the statement load data infile 'tbname.sql' into table newdbname.tbname under the mysql command line.

These are all the knowledge points of this introduction. Thank you for your study and support.

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