简体   繁体   English

将MySQL转储文件导入MSSQL

[英]Import MySQL dump file into MSSQL

Browsermob / Neustar produces a MySQLdump file that you can use to query load test data without incurring cloud hours (which are naturally billable). Browsermob / Neustar生成一个MySQLdump文件,您可以使用它来查询负载测试数据,而不会产生云时间(这是自然可计费的)。 The dump file is a standard dump file, and although I understand that mysqldump has a compatible=mssql option , I am obviously not in a position to run that myself. 转储文件是一个标准的转储文件,虽然我知道mysqldump有一个兼容的= mssql选项 ,但我显然不能自己运行它。 Looking at the contents of the file (which is extremely large) using a text editor seems to show a series of SQL statements ending in a massive bulk insert. 使用文本编辑器查看文件的内容(非常大)似乎显示了一系列以大量批量插入结尾的SQL语句。 I tried to open the file in Microsoft SQL Management Studio but it crashed (known bug) because the file was too large. 我试图在Microsoft SQL Management Studio中打开该文件,但它崩溃了(已知错误)因为文件太大。

So, does anyone know of a tool that will import the MySQL dump file into MsSQL. 那么,有没有人知道将MySQL转储文件导入MsSQL的工具。 The only options I can think of are to install MySQL and import the dump file into that instead and then transfer the data over ODBC, but I really don't want to install MySQL unless I have to. 我能想到的唯一选择是安装MySQL并将转储文件导入到该文件中然后通过ODBC传输数据,但我真的不想安装MySQL,除非我必须这样做。

IMPORTANT: So, just to be clear, I have a dump file, nothing else and I can't access the database, nor re-run the dump with any options. 重要提示:所以,为了清楚起见,我有一个转储文件,没有别的,我无法访问数据库,也没有任何选项重新运行转储。 I have to work with the file I have been given. 我必须处理我给出的文件。

Any ideas? 有任何想法吗?

First lines of the file look like this: 该文件的第一行如下所示:

-- MySQL dump 10.13  Distrib 5.1.58, for debian-linux-gnu (i686)
--
-- Host: localhost    Database: collector
-- ------------------------------------------------------
-- Server version   5.1.58-1ubuntu1

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

DROP TABLE IF EXISTS `name_value_pairs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `name_value_pairs` (
  `id` int(8) unsigned DEFAULT NULL,
  `tx_id` char(24) NOT NULL,
  `step_id` int(8) unsigned DEFAULT NULL,
  `name` varchar(100) NOT NULL,
  `value` varchar(100) DEFAULT NULL,
  KEY `name_value_pairs_id` (`id`),
  KEY `name_value_pairs_tx_id` (`tx_id`),
  KEY `name_value_pairs_step_id` (`step_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `name_value_pairs`
--

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

--
-- Table structure for table `object`
--

DROP TABLE IF EXISTS `object`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `object` (
  `bytes` int(10) unsigned NOT NULL,
  `domain` varchar(255) NOT NULL,
  `end_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `err_msg` varchar(255) DEFAULT NULL,
  `host` varchar(255) NOT NULL,
  `method` varchar(16) DEFAULT NULL,
  `obj_id` int(8) unsigned NOT NULL,
  `obj_num` mediumint(4) unsigned NOT NULL,
  `path` varchar(4096) NOT NULL,
  `partial_url_md5` varchar(32) NOT NULL,
  `protocol` varchar(16) NOT NULL,
  `resolved_ip_addr` varchar(255) DEFAULT NULL,
  `start_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `status_code` smallint(4) NOT NULL,
  `step_id` int(8) unsigned NOT NULL,
  `time_active` mediumint(6) unsigned DEFAULT NULL,
  `blocked_time` mediumint(6) unsigned DEFAULT NULL,
  `dns_lookup_time` mediumint(6) unsigned DEFAULT NULL,
  `connect_time` mediumint(6) unsigned DEFAULT NULL,
  `ssl_handshake_time` mediumint(6) unsigned DEFAULT NULL,
  `send_time` mediumint(6) unsigned DEFAULT NULL,
  `time_to_first_byte` mediumint(6) unsigned DEFAULT NULL,
  `receive_time` mediumint(6) unsigned DEFAULT NULL,
  `tx_id` char(24) NOT NULL,
  `url` varchar(4096) NOT NULL,
  KEY `object_partial_url_md5` (`partial_url_md5`),
  KEY `object_obj_id` (`obj_id`),
  KEY `object_obj_num` (`obj_num`),
  KEY `object_step_id` (`step_id`),
  KEY `object_tx_id` (`tx_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `object`
--

LOCK TABLES `object` WRITE;
/*!40000 ALTER TABLE `object` DISABLE KEYS */;

Then comes the bulk insert. 然后是批量插入。

This information in the file is only to delete and recreate the schema of the database (that I assume you already have), so you probably don't need that. 文件中的此信息仅用于删除和重新创建数据库的模式(我假设您已经拥有),因此您可能不需要这样做。

The bulk insert part is the interesting, probably you can isolate that part for each table to different files and upload it to MsSQL with BULK INSERT from T-SQL, you are able to define delimiter and other settings for this BULK insert you it should fit whatever format you have.. 批量插入部分很有意思,可能你可以将每个表的那个部分隔离到不同的文件并使用BULK INSERT从T-SQL上传到MsSQL,你可以为它应该适合的BULK插入定义分隔符和其他设置你有什么格式..

That's official docs MS docs. 这是官方文档MS文档。

Migrating MySQL to Microsoft SQL Server 2000 http://technet.microsoft.com/en-us/library/cc966396.aspx 将MySQL迁移到Microsoft SQL Server 2000 http://technet.microsoft.com/en-us/library/cc966396.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM