MySQL导入问题

时间:2016-08-13 07:40:15

标签: mysql database utf-8

我正在尝试将数据库从一个数据库导出到另一个数据库。我使用以下命令导出和导入:

export: mysqldump -u root -p dwad dwadallauth.sql
import: $ mysql -u root -p dwad < dwadallauth.sql

然后我检查了很明显原始数据库是使用:

创建的
CREATE DATABASE dwad CHARACTER SET utf8 COLLATE utf8_general_ci;

然后授予权限如下:

GRANT ALL PRIVILEGES ON dwad.* TO 'dwad'@'localhost' IDENTIFIED BY '9LSo1SxqdJF45PL';

所以我尝试了以下导入:

import: $ mysql -u root -p --default-character-set=utf8 dwad < dwadallauth.sql

但是,每当我尝试导入时,都会收到以下错误:

ERROR 1064 (42000) at line 54: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL,
  `sent` datetime(6) DEFAULT NULL,
  `key` varchar(64) NOT NULL,
 ' at line 3

我已经检查过,MySQL版本如下:

Export: mysql  Ver 14.14 Distrib 5.7.13, for Linux (armv7l) using  EditLine wrapper

Import: mysql  Ver 14.14 Distrib 5.5.50, for debian-linux-gnu (x86_64) using readline 6.3

我希望有人能够指出我正确的方向,非常感谢提前。

PS

以下是导出创建的SQL文件的副本:

-- MySQL dump 10.13  Distrib 5.7.13, for Linux (armv7l)
--
-- Host: localhost    Database: dwad
-- ------------------------------------------------------
-- Server version       5.7.13-0ubuntu0.16.04.2

/*!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 `account_emailaddress`
--

DROP TABLE IF EXISTS `account_emailaddress`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `account_emailaddress` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(254) NOT NULL,
  `verified` tinyint(1) NOT NULL,
  `primary` tinyint(1) NOT NULL,
  `user_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`),
  KEY `account_emailaddress_user_id_2c513194_fk_auth_user_id` (`user_id`),
  CONSTRAINT `account_emailaddress_user_id_2c513194_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `account_emailaddress`
--

LOCK TABLES `account_emailaddress` WRITE;
/*!40000 ALTER TABLE `account_emailaddress` DISABLE KEYS */;
/*!40000 ALTER TABLE `account_emailaddress` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `account_emailconfirmation`
--

DROP TABLE IF EXISTS `account_emailconfirmation`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `account_emailconfirmation` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` datetime(6) NOT NULL,
  `sent` datetime(6) DEFAULT NULL,
  `key` varchar(64) NOT NULL,
  `email_address_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `key` (`key`),
  KEY `account_ema_email_address_id_5b7f8c58_fk_account_emailaddress_id` (`email_address_id`),
  CONSTRAINT `account_ema_email_address_id_5b7f8c58_fk_account_emailaddress_id` FOREIGN KEY (`email_address_id`) REFERENCES `account_emailaddress` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

2 个答案:

答案 0 :(得分:1)

根据mysql 5.7的手册:

  

使用逻辑降级方法支持降级多个版本级别,但前提是您一次降级一个版本级别。例如,您可以从5.7降级到5.6,然后降级到5.5。

你试图一步从5.7到5.5。这可能会导致您的问题。

请参阅https://dev.mysql.com/doc/refman/5.7/en/downgrading.html

答案 1 :(得分:1)

旧版本不支持

datetime(6)。在降级期间你将不得不失去微秒。