[英]Phpmyadmin export issue
My shared host does not allow SSH access. 我的共享主机不允许SSH访问。 I am trying to export a database using phpmyadmin and import onto a new server.
我正在尝试使用phpmyadmin导出数据库并导入到新服务器上。 I keep getting this error and i am not sure how to fix it.
我一直收到这个错误,我不知道如何解决它。 Any help is appreciated.
任何帮助表示赞赏。
Error
SQL query:
--
-- Indexes for dumped tables
--
--
-- Indexes for table `EWRporta_blocks`
--
ALTER TABLE `EWRporta_blocks` ADD PRIMARY KEY ( `block_id` ) ,
ADD KEY `title` ( `title` ) ;
MySQL said: Documentation
#1068 - Multiple primary key defined
I have run into this issue multiple times, and modonoghue has one valid way of handling it by dropping your tables and completely recreating them. 我多次遇到这个问题,modonoghue有一种有效的方法来处理它,删除你的表并完全重新创建它们。
Basically what is happening is that you are trying to run INSERT statements that are inserting values into primary keys that already exist - thereby giving you an error of duplicate keys. 基本上发生的事情是您正在尝试运行INSERT语句,这些语句将值插入已存在的主键中 - 从而给出错误的重复键。 The database has no clue how to handle having multiple entries with the same key, as SQL logic is based around every 'row' having a primary key that is completely unique.
数据库不知道如何处理具有相同键的多个条目,因为SQL逻辑基于具有完全唯一的主键的每个“行”。
What you want to do is to save all the values to your exported sql file, in a query that, when you import the file again, deletes all the existing values (assuming you want to restore it to a certain point and aren't worrying about data saved between your export date and your import date!) and inserts all the exported values ... or somehow else avoids trying to add a new entry with an existing key (see following). 你想要做的是所有的值保存到出口SQL文件,在查询中,当您再次导入该文件, 删除所有现有的值(假设你想将它恢复到某一点,而不是令人担忧关于在导出日期和导入日期之间保存的数据!)并插入所有导出的值...或者以其他方式避免尝试添加具有现有密钥的新条目(请参阅下文)。
When you import, all the existing data will be deleted from each table (TRUNCATE) and all the exported data will be written back to the tables (INSERT) but the tables themselves won't be deleted (DROP). 导入时,将从每个表中删除所有现有数据(TRUNCATE),并将所有导出的数据写回表(INSERT),但不会删除表本身(DROP)。
You should be able to skip Step 3 above (TRUNCATE) and instead select the checkbox "Instead of INSERT Statements Use ..." "INSERT IGNORE statements" 您应该能够跳过上面的步骤3(TRUNCATE),而是选中复选框“而不是INSERT语句使用...”“INSERT IGNORE语句”
Basically, "IGNORE" will just skip over duplicates in your exported data, and prevents you from having to delete your existing data. 基本上,“IGNORE”将跳过导出数据中的重复项,并防止您必须删除现有数据。 This is good if you want to just add back lost data, without deleting data that's been changed / added since the last export.
如果您只想添加丢失的数据,而不删除自上次导出后已更改/添加的数据,这是很好的。
There is also an INSERT INTO ... ON DUPLICATE KEY UPDATE ... that allows you to tell the query exactly what to do if there is a duplicate key. 还有一个INSERT INTO ... ON DUPLICATE KEY UPDATE ...允许您在有重复键的情况下告诉查询确切的操作。 This prevents you from just ignoring two entries with identical keys that may not be identical entries.
这可以防止您忽略具有相同键的两个条目,这两个条目可能不是相同的条目。 It is more complicated to setup properly, however.
但是,正确设置会更复杂。
As others have said, drop and recreate the tables. 正如其他人所说,放弃并重新创建表格。 In phpmyadmin, select the check box labeled "add DROP TABLE" when doing the export.
在phpmyadmin中,选择导出时标记为“add DROP TABLE”的复选框。 Then the issue described should be resolved on import.
然后应该在导入时解决所描述的问题。
Remove comment Generated by export tool 删除评论由导出工具生成
--
-- Indexes for dumped tables
--
--
-- Indexes for table `EWRporta_blocks`
--
and try to execute query as follow only 并尝试执行查询,如下所示
ALTER TABLE EWRporta_blocks
ADD PRIMARY KEY ( block_id
) , ADD KEY title
( title
) ; ALTER TABLE
EWRporta_blocks
ADD PRIMARY KEY( block_id
),ADD KEY title
( title
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.