• Resolved writermuhammadzakaullah

    (@writermuhammadzakaullah)


    Hi, I get the following error when trying to activate high-performance keys or revert them on some tables:
    Key column ‘option_id’ doesn’t exist in table
    I have uploaded diagnostic data via the id YrQ6U9cu
    Please help me.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author OllieJones

    (@olliejones)

    Somehow, your wp_options table has a missing key.

    Issue this MySQL data definition language (DDL) statement

    ALTER TABLE wp_options ADD UNIQUE KEY option_id(option_id)

    and your problem should be fixed.

    I can’t begin to guess how that key got lost, sorry to say.

    If you have WP-CLI support you can issue that DDL with this line of a shell script command:

    wp db query "ALTER TABLE wp_options ADD UNIQUE KEY option_id(option_id)"

    Or you can use phpmyadmin or some other SQL client program.

    • This reply was modified 1 year, 5 months ago by OllieJones.
    Thread Starter writermuhammadzakaullah

    (@writermuhammadzakaullah)

    Yes, the option_id column was missing in the wp_options table. I moved my site from one host to another using the updraftplus backup plugin, and I think this plugin is to blame.
    I created the said column using phpmyadmin, and adjusted the values based on another site which is intact and is on the previous host. Since there was no option_id column in the wp_options table, the primary key was assigned to the option_name column, which I reverted to the option_id column. Now the plugin can add high-performance keys and revert to default ones successfully.
    I was hoping you’d reply in a day or so, so I decided to fix it myself.
    I came here to share how I fixed it to help others, since Google was of minimal help in my case. Was glad to find you had responded so quick.
    Wonderful creators, wonderful plugin.

    Thanks again for giving us such a plugin and providing timely support.

    Can you please tell me how you primary key was assigned primary key to option_id column. I was unable to do this through phpmyaddmin.

    • This reply was modified 1 year, 4 months ago by todayer.
    Plugin Author OllieJones

    (@olliejones)

    Sorry, I don’t understand your question. If you have installed this plugin, please visit the Tools -> Index MySQL -> About tab, upload your metadata, and let me know the upload id. Then I can take a look.

    https://www.plumislandmedia.net/index-wp-mysql-for-speed/about/

    AChrJMZA

    Plugin Author OllieJones

    (@olliejones)

    OK, I see the problem. Give this command to phpmyadmin.

    ALTER TABLE wp_options DROP KEY option_name ADD UNIQUE KEY option_id(option_id);

    And you should be good.

    According to your uploaded metadata, your wp_options keys were like this:

    PRIMARY KEY (option_name)
    UNIQUE KEY option_name (option_name)
    KEY autoload (autoload)

    That’s wrong because there’s a duplicate key on the option_name column and no unique key on option_id. The ALTER TABLE data-definition-language statement should rectify the situation. Explanation.

    I honestly don’t know how your table got into this situation.

    • This reply was modified 1 year, 4 months ago by OllieJones.

    Hello. I am thankful for your reply. Now I am getting this kind of error: 1072 key column ‘option_id’ doesn’t exist in table

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Key column ‘option_id’ doesn’t exist in table’ is closed to new replies.