mysqldump脚本上无效的utf8字符串

时间:2019-05-22 18:58:57

标签: mysql flyway mysql-5.5

我已经创建了一个数据库副本,并将归类和字符集更改为utf8mb4(最初是latin1),然后使用mysqldump为{{ 1}}数据库迁移。

当我运行以下脚本时

Flyway

flyway显示以下消息:

-- MySQL dump 10.13  Distrib 5.5.62, for Win64 (AMD64)
--
-- Host: localhost    Database: feedback
-- ------------------------------------------------------
-- Server version   8.0.15

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Dumping data for table `COMPONENT_GROUP`
--

LOCK TABLES `COMPONENT_GROUP` WRITE;
/*!40000 ALTER TABLE `COMPONENT_GROUP` DISABLE KEYS */;
INSERT INTO `COMPONENT_GROUP` VALUES ('AAAB','AAA - MOTOR','LUBRIFICAÇÃO DO MOTOR','LUBRIFICAÇÃO DO MOTOR',NULL,NULL,20181219,1)
UNLOCK TABLES;


/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2019-05-22 13:07:38

当我使用SQLyog和MySQL Workbench之类的工具运行转储脚本时,数据已正确插入,那么如何为Flyway修复该问题?

2 个答案:

答案 0 :(得分:0)

您正在使用哪个版本的Flyway?

如果尚未完成,请查看此封闭的issue。 希望对您有所帮助。

答案 1 :(得分:0)

找到缺少的部分来解决迁移问题。我必须在Flyway的连接字符串中添加编码设置:

FLYWAY_URL="jdbc:mysql://${db_instance.default.address}:3306/${mysql_database.db-app.name}?characterEncoding=UTF-8&useUnicode=true"