简体   繁体   English

无法将mysql数据从一个数据库传输到另一个数据库

[英]Can't transfer mysql data from one database to another

I am trying to rework an old implementation of osCommerce and re-introduce data from the old database to the new one. 我正在尝试对osCommerce的旧实现进行重做,并将数据从旧数据库重新引入新数据库。 I exported the data from the old tables using phpMyAdmin. 我使用phpMyAdmin从旧表中导出数据。 When I tried to import them to the new database, I got a series of errors. 当我尝试将它们导入新数据库时,我遇到了一系列错误。 I am simplifying the problem here to a single INSERT statement for the sake of clarity. 为了清楚起见,我将这里的问题简化为单个INSERT语句。

The statement is: 该语句是:

INSERT INTO `address_book` (`address_book_id`, 
                            `customers_id`, 
                            `entry_gender`,
                            `entry_company`, 
                            `entry_firstname`, 
                            `entry_lastname`, 
                            `entry_street_address`, 
                            `entry_suburb`, 
                            `entry_postcode`, 
                            `entry_city`, 
                            `entry_state`, 
                            `entry_country_id`, 
                            `entry_zone_id`) 
  VALUES (1, 1, 'm', '', 'Mary', 'Smith', 
          '1234 Pleasant Court', '', '67890',
          'Hometown', 'state', 123, 0);

When I try to import it from a file through phpMyAdmin I get an error: “#1064 - 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 '' at line 1.” 当我尝试通过phpMyAdmin从文件导入它时,出现错误: “#1064 - 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 '' at line 1.” “#1064 - 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 '' at line 1.”

If I click the Edit button and resubmit the query, I get another error: “#1062 - Duplicate entry '1' for key 'PRIMARY'.” The address_book_id field is the primary key in this table and is an auto-increment field. 如果我单击“编辑”按钮并重新提交查询,我会收到另一个错误: “#1062 - Duplicate entry '1' for key 'PRIMARY'.” address_book_id字段是此表中的主键,是一个自动增量字段。

Still in the edit screen, if I change the address_book_id value to NULL and resubmit, the query is accepted. 仍然在编辑屏幕中,如果我将address_book_id的值更改为NULL并重新提交,则查询被接受。

Thinking I had the issue resolved, I changed the address_book_id value in the import file to NULL and tried importing again. 考虑到问题已解决,我将导入文件中的address_book_id值更改为NULL,然后尝试再次导入。 And again, I get the #1064 error. 再一次,我得到#1064错误。 I immediately clicked edit. 我立即点击编辑。 I made no edits to the statement but submitted it without change. 我没有对声明进行任何修改,但是没有修改就提交了。 This time, the statement was accepted. 这一次,声明被接受了。

It appears to be a problem with handling the address_book_id value in the downloaded data. 处理下载数据中的address_book_id值似乎是个问题。 I have hundreds of index values from numerous tables from the old database. 我从旧数据库的众多表中获得了数百个索引值。 Obviously, I don't want to have to change the index values and submit them one at a time. 显然,我不想更改索引值并一次提交一个。

I am working with phpMyAdmin 3.5.1. 我正在使用phpMyAdmin 3.5.1。 Any idea what is going on? 知道发生了什么事吗?

Do it without the address_book_id . 不用address_book_id Apparently that one is the primary key which you can't simply copy from another table. 显然,一个是主键,您不能简单地从另一个表中复制它。 The new ID should be assigned automatically. 应该自动分配新的ID。

After playing around with this for a while, I think the best approach is to delete then recreate the tables. 玩了一段时间后,我认为最好的方法是删除然后重新创建表。 I tried this on two tables and was then able to upload my data, including the id fields without throwing any errors. 我在两个表上进行了尝试,然后能够上传我的数据,包括id字段,而不会引发任何错误。 The tables seem to be working OK. 表似乎工作正常。

暂无
暂无

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

相关问题 将数据从一个数据库传输到另一个 MYSQL - Transfer data from one database to another MYSQL Postgres到Mysql-每天将数据从一个数据库传输到另一个数据库 - Postgres to Mysql - Transfer data from one database to another every day 如何自动将数据从一个MySQL数据库传输到另一个MySQL数据库? - How to transfer data automatically from one MySQL Database to another MySQL Database? 如何将数据从一个mysql数据库传输到另一个数据库,以及如何使用python映射具有不同列名的数据 - how to transfer data from one mysql database to another and mapping the data with different column names using python SQL查询:数据从一个数据库传输到另一个数据库 - SQL query : Data transfer from one database to another database Python脚本将数据从一台MySQL服务器传输到另一台MySQL服务器 - Python script to transfer data from one MySQL server to another one Mysql-如何在每周的特定日期和时间将数据从一个表转移到另一个表? - Mysql - How can I transfer data from one table to another on a specific day and time in the week, every week? MYSQL将数据从一个表转移到另一个表的过程 - MYSQL Procedure to transfer data from one table to another 将数据从一个 MySQL 表传输到另一个带参数的表 - Transfer data from one MySQL table to another w/ parameters 无法将数据从数据库复制到另一个? MYSQL - can't copy data from database to another? MYSQL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM