2016-08-13 121 views
1

我正在嘗試將數據庫從一個數據庫導出到另一個數據庫。我使用下面的命令導出和導入:MySQL導入問題

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 5.7

-- 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 @[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 @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 

/*!40101 SET @[email protected]@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 

/*!40111 SET @[email protected]@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 */; 

回答

1

根據手冊:

Downgrading more than one release level is supported using the logical downgrade method, but only if you downgrade one release level at a time. For example, you can downgrade from 5.7 to 5.6, and then to 5.5.

您正在嘗試從去一步到位5.7到5.5。這可能會導致您的問題。

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

+0

升級到版本5.6,它工作完美。非常感謝,艾倫。 –

1

datetime(6)在舊版本不支持。在降級期間您將不得不失去微秒。

+0

澄清 - 'FRAC_SECOND'(有很多限制)直到5.5.3存在,當它更改爲'MICROSECOND'時。 5.6.4 TIME,DATETIME,TIMESTAMP中的小數秒(微秒)支持。 –