MySQL 新版本的 PHPMyAdmin 使我无法编辑数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18227094/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:31:57  来源:igfitidea点击:

New version of PHPMyAdmin has stopped me being able to edit data

mysqlphpmyadmin

提问by SammyBlackBaron

PHPMyAdmin has just been upgraded by my server admin to v4.0.4.2.

PHPMyAdmin 刚刚被我的服务器管理员升级到 v4.0.4.2。

Now I am unable to edit rows in the following table:

现在我无法编辑下表中的行:

CREATE TABLE IF NOT EXISTS `product_options` (
  `product_id` int(10) NOT NULL,
  `option_id` int(10) NOT NULL,
  KEY `product_id` (`product_id`,`option_id`)
)

PHPMyAdmin just returns this error message when I browse data in the table:

当我浏览表中的数据时,PHPMyAdmin 只会返回此错误消息:

This table does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available.

This table does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available.

I don't want a unique column in this table, so how can I edit data? Is there a setting I can change?

我不希望此表中有唯一列,那么如何编辑数据?有我可以更改的设置吗?

Many thanks

非常感谢

MySQL v5.1.70

MySQL v5.1.70

EDIT/SOLUTION

编辑/解决方案

I realised that it wasn't necessarily a new unique columnPHPMyAdmin was wanting me to create, but instead a unique index. This means that the structure of my tables didn't have to change - I just had to add a unique index, which I should have been doing anyway.

我意识到这不一定是一个新的unique columnPHPMyAdmin 要我创建,而是一个unique index. 这意味着我的表的结构不必更改 - 我只需要添加一个唯一索引,无论如何我应该这样做。

回答by Michal ?iha?

Without unique key, there is no way to differentiate between two same records which can exists. Therefore phpMyAdmin can not safely edit the table - you have no clue which of these would end up edited. Do you really want to have duplicate records in this table?

如果没有唯一键,就无法区分可以存在的两个相同记录。因此 phpMyAdmin 不能安全地编辑表格 - 您不知道哪些最终会被编辑。你真的想在这个表中有重复的记录吗?

回答by zvzej

All you got to do is add a unique column like one called id with a index = PRIMARY like the pic, or if you have one already that is called id that are numbers just make it PRIMARY

你所要做的就是添加一个独特的列,比如一个叫做 id 的列,一个索引 = PRIMARY 就像图片一样,或者如果你已经有一个叫做 id 的数字,那就让它成为 PRIMARY

enter image description here

在此处输入图片说明

回答by Birkhoff Lee

You can just add a field that name is "id", and check A_I option.

您可以添加一个名称为“id”的字段,然后选中 A_I 选项。

回答by runningmark

I found a solution which might help someone in future, I had table with id, which was not primary key and not auto increment, i added tempcolumn, made it primary and auto increment, then i edited the id column and then i removed the tempcolumn, after that i changed idto primary and auto increment

我找到了一个可能在未来对某人有所帮助的解决方案,我有一个带有 id 的表,它不是主键,也不是自动增量,我添加了temp列,使其成为主要和自动增量,然后我编辑了 id 列,然后我删除了该temp列, 之后我改为id主要和自动增量

回答by Obinna Nnenanya

I had the same issue. In my own case I already had an id column. I dropped the column and recreated it; this time I made it a primary key and ticked A_I (ie Auto-Increment). Everything went fine.

我遇到过同样的问题。在我自己的情况下,我已经有一个 id 列。我删除了该列并重新创建了它;这次我把它作为主键并勾选了A_I(即自动增量)。一切都很顺利。

Note: You can only do this if changing your IDs does not affect your work.

注意:您只能在更改 ID 不影响您的工作时执行此操作。

回答by jaro21

In my experience, you have more than 2 primary keys or you don't have any primary key.

根据我的经验,您有 2 个以上的主键,或者您没有任何主键。

回答by T.Todua

Before checking the AUTO_INCREMENToption, check that the column is INTinstead of VARCHAR.

在检查该AUTO_INCREMENT选项之前,请检查该列是否INTVARCHAR