当前位置:网站首页>. 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
- ES6-Const常量与数组解构
- Unity技术手册 - 生命周期旋转RotationOverLifetime-速度旋转RotationBySpeed-及外力
- 2022-2028 global horizontal reciprocating compressor industry research and trend analysis report
- Oracle -- table operation
- What is 5g? What can 5g do? What will 5g bring in the future?
- Unity technical manual - getKey and getaxis and getbutton
- Glory launched the points mall to support the exchange of various glory products
- 2022-2028 global cloud based remote browser isolation industry research and trend analysis report
- adb常用命令
猜你喜欢
2022-2028 global industrial touch screen industry research and trend analysis report
Utilisation de la classe Ping d'Unity
2022-2028 global open source cloud storage industry research and trend analysis report
2022-2028 global TFT touch screen industry research and trend analysis report
荣耀推出积分商城,支持兑换各种荣耀产品
2022-2028 global iridium electrode industry research and trend analysis report
2022-2028 global transmission type photoelectric circuit breaker industry research and trend analysis report
2022-2028 global variable frequency compressor technology industry research and trend analysis report
2. What is the geometric meaning of a vector multiplying its transpose?
Es7/es9 -- new features and regularities
随机推荐
adb常用命令
Yyds dry goods inventory JD 2, why is redis so fast?
Record the learning record of the exists keyword once
Some reflections on preparing for the Blue Bridge Cup
Raspberry PI (bullseye) replacement method of Alibaba cloud source
Global and Chinese flame retardant ABS industry development trend and market demand analysis report 2022 ~ 2028
ES6 learning -- let
Common MySQL database functions and queries
What are the channels for Internet advertising to gain customers?
The Ping class of unity uses
2022-2028 global extrusion coating and lamination production line industry research and trend analysis report
22 years of a doctor in Huawei
Unity technical manual - particle emission and life cycle velocity sub module
Flex & Bison 開始
民航局:到 2025 年我国将初步建成安全、智慧、高效和绿色的航空物流体系
Glory launched the points mall to support the exchange of various glory products
实战:typora里面如何快捷改变字体颜色(博客分享-完美)-2022.6.25(已解决)
关闭MongoDB一些服务需要注意的地方(以及开启的相关命令)
Unity technical manual - getKey and getaxis and getbutton
2022-2028 global web and browser isolation platform industry research and trend analysis report