flyf编码utf8的问题

时间:2017-12-08 04:17:19

标签: flyway

我正在尝试使用Flyway迁移MySQL数据库,除了我的编码问题与cyrilic符号被替换为'?'登录。

我正在使用以下Maven插件。

<plugin>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-maven-plugin</artifactId>
    <version>4.2.0</version>
    <configuration>
        <user>mysql</user>
        <password>password</password>
        <url>jdbc:mysql://192.168.1.6/schem2</url>
        <encoding>UTF-8</encoding>
        <schemas>
            <schema>schem2</schema>
        </schemas>
    </configuration>
</plugin>
数据源bean中的

......

jdbc:mysql://192.168.1.6/schem2?useUnicode=true&characterEncoding=UTF-8

似乎无处不在指定编码。

脚本...

-- MySQL dump 10.13  Distrib 5.7.12, for Win64 (x86_64) 
--
-- Host: 192.168.1.6    Database: schem2
-- ------------------------------------------------------
-- Server version   5.5.50-MariaDB

/*!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 utf8 */;
/*!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 */;

--
-- Table structure for table `instbl`
--

DROP TABLE IF EXISTS `instbl`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `instbl` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `INN` varchar(12) DEFAULT NULL,
  `OGRN` varchar(13) DEFAULT NULL,
  `FULLNAME` varchar(255) DEFAULT NULL,
  `ADRESS` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`ID`)
 ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `instbl`
--

LOCK TABLES `instbl` WRITE;
/*!40000 ALTER TABLE `instbl` DISABLE KEYS */;
INSERT INTO `instbl` VALUES (1,'11111111111','10000000000','компания1','634 
пр.Ленина д.1'),(2,'564441111111','1111','frfrf','wrfwerfw3'),
(3,'4545454','4565662','Полное Имя 1','Адресс 1');
/*!40000 ALTER TABLE `instbl` ENABLE KEYS */;
UNLOCK TABLES;
 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!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 */;

1 个答案:

答案 0 :(得分:1)

我在使用土耳其语字符时遇到了同样的问题,它们都被转换为“?”字符正如@ saw303所说,我从

修改了 flyway.url
jdbc:mysql://192.168.11.7:3306/test_db?autoreconnect=true

jdbc:mysql://192.168.11.7:3306/test_db?autoreconnect=true&useUnicode=true&characterEncoding=UTF-8

此修改解决了问题。