0

My query relates to a WordPress website, which is hosted on a VPS.

Earlier today, I needed to upload my backed up Database. Upon completion, I was returned with the message:

SQL query:

ALTER TABLE 'wp_options'
ADD PRIMARY KEY ('option_id)
ADD UNIQUE KEY 'option_name' ('option_name')

MySQL said:

#1062 - Duplicate entry '0' for key 'PRIMARY'

The website seems to have fully uploaded, with all of its content, however (and I am not sure if this is connected) when I edit a page and select 'Update', it does not seem to save the modifications.

I am hoping that by resolving the database issue, the other issue will look after itself.

If anyone could provide me with a straight forward fix, it would be much appreciated.

Thanks.

Craig

3
  • wp_options table have multiple entries with same id number. So it is unable to make that column primary key/unique keys. Try to open the database in a tool like phpmyadmin, remove the dupilcate entries manuelly, and rerun the sql statement that failed Commented May 27, 2016 at 22:27
  • Can you execute a query against wp_options: select option_name, count(option_name) from wp_options o1 where (select count(1) from wp_options o2 where o1.option_name = o2.option_name) > 1 group by option_name; and add that to your question? We should look to see what items are duplicates. And do the same for option_id too. Commented May 27, 2016 at 22:29
  • When you imported your backed up database, did you clear out any old data from your existing tables, or did you already have data in there before you imported your backup? You may need to just determine your duplicates and purge them. Commented May 27, 2016 at 22:32

1 Answer 1

1

Maybe you need auto incrément on primary key

MySQL doc say :

To start with an AUTO_INCREMENT value other than 1, set that value with CREATE TABLE or ALTER TABLE, like this:

mysql> ALTER TABLE tbl AUTO_INCREMENT = 100;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.