将MySQL表从一台服务器导入到另一台服务器

将MySQL表从一台服务器导入到另一台服务器,mysql,import,export,mysql-workbench,Mysql,Import,Export,Mysql Workbench,我需要将表从一台MySQL服务器导入到另一台MySQL服务器。需求看起来很简单,但我尝试了两种方法,无法导入数据。请查找以下我尝试导入数据的详细信息和方法 我们在服务器A中有一个现有表,其引擎类型为MyISAM,没有主键,并且包含重复的记录 现在,我们需要将这个表导出到一个新的MySQL服务器(服务器B),但是新的MySQL数据库有一些规则 引擎应为InnoDB 每个表都应该包含一个主键 下面是我尝试导入的方法,但失败了 方法1:- Exported the data from server

我需要将表从一台MySQL服务器导入到另一台MySQL服务器。需求看起来很简单,但我尝试了两种方法,无法导入数据。请查找以下我尝试导入数据的详细信息和方法

  • 我们在服务器A中有一个现有表,其引擎类型为MyISAM,没有主键,并且包含重复的记录

  • 现在,我们需要将这个表导出到一个新的MySQL服务器(服务器B),但是新的MySQL数据库有一些规则

    • 引擎应为InnoDB
    • 每个表都应该包含一个主键
  • 下面是我尝试导入的方法,但失败了

    方法1:-

    Exported the data from server A with Outfile command using MySQL Workbench 
    and tried to import with Infile command but due to the "mandatory primary key" validation all the 
    rows were not inserted. So to avoid this added an incremental column in new table and tried to 
    import but again it's failed due to the no.of columns mismatch error
    
    Configured both the servers in MySQL WorkBench and exported the table in Server A
    with MANAGEMENT-> Data Export and tried to Import with MANAGEMENT-> Data Import/Restore
    but due to the engines mismatch between the two tables again it's failed to import the data. 
    (Tried with Dump project folder and self contained folder).
    
    方法2:-

    Exported the data from server A with Outfile command using MySQL Workbench 
    and tried to import with Infile command but due to the "mandatory primary key" validation all the 
    rows were not inserted. So to avoid this added an incremental column in new table and tried to 
    import but again it's failed due to the no.of columns mismatch error
    
    Configured both the servers in MySQL WorkBench and exported the table in Server A
    with MANAGEMENT-> Data Export and tried to Import with MANAGEMENT-> Data Import/Restore
    but due to the engines mismatch between the two tables again it's failed to import the data. 
    (Tried with Dump project folder and self contained folder).
    
    好了,现在我只有一个选择了(由于数据太大,我不想这么做)

    • 将数据导出为CSV文件,然后使用“表数据导入向导”将其导入

    请告诉我是否有任何其他选项导入数据

    您可以尝试将新的auto inc列添加到源表中(同时添加主键,以检查是否没有问题)。为了完成这项工作,您还可以将表转换为InnoDB引擎,并以最小的摩擦将其复制