当前位置:网站首页>. SQL database import error: / *! 40101 SET @OLD_ COLLATION_ [email protected]@COLLATION_ CONNECTION */
. SQL database import error: / *! 40101 SET @OLD_ COLLATION_ [email protected]@COLLATION_ CONNECTION */
2022-06-25 23:09:00 【KFC home delivery specialist】
Error phenomenon
adopt navicat Import sql File failed .
Screenshot of error reporting


Troubleshooting of error reporting reasons
1. First, check whether it is due to sql The file contains a large number of comments
I began to think it was through mysqldump Command export database , Exported sql There is a lot of annotation information in the Chinese back . Unrecognized when importing , Later, I searched the meaning of the notes and found that it didn't seem to be .
1) Meaning of notes /*! Back number , In fact, that is mysql Version number information , When the version number is higher than or equal to the version number in the comment , Inside set Orders will be executed .
for example :/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
1)40101, This is a mysql Version number , This number tells us that these statements are only available if they are greater than or equal to the version mysql In order to execute , That is to say mysql4.01.01 And above mysql In the implementation of
2)set Statement is to set the current system variable CHARACTER_SET_CLIENT The value is assigned to OLD_CHARACTER_SET_CLIENT
2) Prohibit... While importing data / Activate index
explain :
DISABLE KEYS It is forbidden to index
ENABLE KEYS Is to activate the index
When inserting data , The index will be disabled first , Reactivate the index , This saves time importing data
LOCK TABLES `tb_shop_order` WRITE;
/*!40000 ALTER TABLE `tb_shop_order` DISABLE KEYS */;
INSERT INTO `tb_shop_order` VALUES (1,1,1,1,1.000000,1.000000,'1','1','1',1,'1','2020-02-20 00:00:00',1,'2020-02-20 00:00:00',1,'2020-02-20 00:00:00','1')
/*!40000 ALTER TABLE `tb_shop_order` ENABLE KEYS */
3) The following comment statement appears at the end of the backup file , Use set To restore the original value of the server system variable :
/*!40103 SET [email protected]_TIME_ZONE */;
/*!40101 SET [email protected]_SQL_MODE */;
/*!40014 SET [email protected]_FOREIGN_KEY_CHECKS */;
/*!40014 SET [email protected]_UNIQUE_CHECKS */;
/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;
/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;
/*!40101 SET [email protected]_COLLATION_CONNECTION */;
/*!40111 SET [email protected]_SQL_NOTES */;
Reference resources blog:
MySQL Annotation form _ Executable comment statements (/*!...*/)_ Database comments _ Database script comments _SQL Script comment format _SQL Script comment classification _liaowenxiong The blog of -CSDN Blog _mysql Script comment Why should the article directory be executable SQL The statement is written in the comment ? Comment example other comment statements /*!...*/ This is called an executable comment (executable comments), The statement in the comment will be MySQL Normal parsing and execution , But in other DBMS it will be ignored as a comment , This can improve the portability of database scripts . Why put executable SQL The statement is written in the comment ?MySQL Contains some other DBMS Function extensions not available in , If you use them , Will not be able to migrate code to other DBMS in . In some cases , You can write something that contains MySQL Code for special extension functions , But it still keeps its https://blog.csdn.net/liaowenxiong/article/details/117223010 Use sed Command deletion SQL Comment information in the file When we need to migrate databases , And the data is from the lower version mysql Migrate to a higher version of mysql Use , Use mysqldump Command export database , Exported SQL There will be a lot of annotation information in , as follows : / !40101 SET @[email protected]@CHARACTER_SET_CLIENT /; / !40101 SET @[email protected]@CHARACTER_SET_RESULTS /; / !40101 SET @[email protected]@COLLATION_CONNECTION /; / !40101 SET NAMES utf8 /; / !40103 SET @[email protected]@TIME_ZONE /; / !40103 SET TIME_ZONE='+00:00' /; / !40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 /; / !40014 SET @OLD
https://copyfuture.com/blogs-details/20200325114105956muk0wbvlten06s4
2. screening mysql edition
adopt select version() Inquire about MySQL Version of , Found version is 5.6.51, It is greater than 4.01.01 The version of the , Should support

3. navicat Do you support mysqldump Derived sql file
Then I intercepted a paragraph containing comments sql The file goes straight to navicat To perform , It is found that annotations can run through , however mysql Statement error , Vomit and shout to solve the case , therefore navicat Is to support the , yes sql There is a problem in the statement

4. mysql Statement troubleshooting
newspaper Unknown collation: 'utf8mb4_0900_ai_ci' So I passed show charset Check the currently supported character set and the corresponding sorting rules , Can't find utf8mb4 Only found utf8 Character set , Should not support utf8mb4 Character type
Then I went to check CHARSET=utf8mb4 and CHARSET=utf8mb4 The difference between :
utf8 The encoding method indicates that a character needs 1-4 Bytes , But common characters only need 1-3 It's just a byte ; And in the MySQL The maximum byte length used to represent a character in will affect the storage and performance of the system , therefore utf8 It's actually utf8mb3, The box 1-3 The encoding method of byte encoding ;
If there are some special characters in the data ( Such as emoji expression ) Then please use utf8mb4.

solve the problem
Replace the character set in the character set and collation with utf8 Replace the collation with utf8_general_ci

Reference resources blog:
Summary of experience
1. Next time if sql Still can't lead in , You can post a paragraph directly sql Go to the connection query to read the error report , Then row , It can save time and locate the problem more quickly
2. After the replacement, search the keyword globally to see if there is any omission
2022/06/25
边栏推荐
- Unity technical manual - life cycle rotation rotationoverlifetime- speed rotation rotationbyspeed- and external forces
- Common MySQL database functions and queries
- Flex & Bison Start
- How to disable the optical drive
- 2022-2028 global web and browser isolation platform industry research and trend analysis report
- NRM source switching tool
- How to design a complex business system? From the understanding of domain design, cloud native, micro service, and middle platform
- ES6-- 集合
- Intimacy - [comfortable exit] - final communication to reduce injury
- ES6-Const常量与数组解构
猜你喜欢

NRM source switching tool

ES7/ES9 -- 新特性与正则

如何用jmeter做接口测试

Why absolute positioning overlaps

Use apiccloud AVM multi terminal component to quickly realize the search function in the app

2022-2028 global co extrusion production line industry research and trend analysis report

2022-2028 global cloud based remote browser isolation industry research and trend analysis report

字符串变形(字符串大小写切换和变现)

Eureka core ⼼ source code analysis

Utilisation de la classe Ping d'Unity
随机推荐
Why is BeanUtils not recommended?
How to use JMeter for interface testing
Global and Chinese oleic acid operation mode and market supply and demand forecast report 2022 ~ 2028
汇编语言核心要点
22 years of a doctor in Huawei
2022-2028 global DC linear variable differential transformer (LVDT) industry survey and trend analysis report
adb常用命令
Unity的Ping類使用
This 110 year old "longevity" enterprise has been planning for the next century
ES6 -- 形参设置初始值、拓展运算符、迭代器、生成函数
小程序绘制一个简单的饼图
异或运算符简单逻辑运算 a^=b
[eosio] eos/wax signature error is_ Canonical (c): signature is not canonical
Flex & Bison 开始
Pit resolution encountered using East OCR (compile LAMS)
What is 5g? What can 5g do? What will 5g bring in the future?
2022-2028 global transmission type photoelectric circuit breaker industry research and trend analysis report
Unity technical manual - getKey and getaxis and getbutton
Wpewebkit debugging MSE playback
Lecture 14 of the Blue Bridge Cup -- number theory [exercises]