WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Changed table prefix, got "(in)sufficient permissions" error. (10 posts)

  1. guice
    Member
    Posted 6 years ago #

    Same database, new table prefix. All I did was run a rename on all tables from wp_* to delu_*.

    Now, I can't log into the admin with error: "You do not have sufficient permissions to access this page."

    I have a copy of all the old tables: I reloaded them up, changed the prefix back to "wp_" and then everything work. However, since I'm running two wp installs in the same db, I have to change the prefix (fyi, the other install gives me the same error, too) The entire sites, browsing, etc, works with the new prefix "delu_" except the admin section.

    What's going on here? Is the prefix hard coded somewhere else?

  2. Jeremy Clark
    Moderator
    Posted 6 years ago #

    Yes the table prefix is in the wp-config file.

  3. guice
    Member
    Posted 6 years ago #

    Hum, I said "somewhere else."

    Of course I updated the wp-config.php file. I'm sorry; I thought that step was implied when I said "The entire site, browsing, etc, works with the new prefix "delu_" except the admin section."

    It works just fine when it's set to wp_ within the config, but when I changed it to delu_ it errors out.

    The ONLY change I did was renaming the tables. The install was installed with "wp_" as the prefix, which makes me wonder if it's set someplace else. There were no other changes.

  4. MichaelH
    Member
    Posted 6 years ago #

    Yes several values in the usermeta table do use the $table_prefix value (e.g. wp_user_level and wp_capabilities).

  5. guice
    Member
    Posted 6 years ago #

    I hate to be the cynical one here, but please don't tell me you're using $table_prefix as a prefix value for db value names...not only is that poor design, but it will completely screws up any wordpress install if somebody needed to change table prefixes later, which is what I'm trying to do. There is absolutely no coding reason for this -- if two WPs are using the same table prefix, they're going to use the same data anyway. Why would somebody do such a thing?

    Anyway, making said change, in plausible horror, within the usermeta table did not work (I didn't change, just added rows):

    |        3 |       1 | wp_capabilities         | a:1:{s:13:"administrator";b:1;}                                                                                                                                              |
    |        4 |       1 | wp_user_level           | 10                                                                                                                                                                           |
    |        8 |       1 | wp_autosave_draft_ids   | a:9:{i:-1183829714;i:3;i:-1183829763;i:4;i:-1183862174;i:6;i:-1183894955;i:7;i:-1183910552;i:8;i:-1184030565;i:12;i:-1184076999;i:13;i:-1187797134;i:15;i:-1187879004;i:16;} |
    |        9 |       1 | goma_user_level         | 10                                                                                                                                                                           |
    |       10 |       1 | goma_capabilities       | a:1:{s:13:"administrator";b:1;}                                                                                                                                              |
    |       11 |       1 | goma_autosave_draft_ids | a:9:{i:-1183829714;i:3;i:-1183829763;i:4;i:-1183862174;i:6;i:-1183894955;i:7;i:-1183910552;i:8;i:-1184030565;i:12;i:-1184076999;i:13;i:-1187797134;i:15;i:-1187879004;i:16;} |

    As you see, exact copies of the rows and no go.

    (goma is the other site I was referring to that's broken. It's less "live" as the one above I'm trying to fix)

  6. guice
    Member
    Posted 6 years ago #

    Any body else have any ideas? My WordPress install still isn't working. WP is suppose to be able to work with different table prefixes.

    Help, please?

  7. Jeremy Clark
    Moderator
    Posted 6 years ago #

    WP is suppose to be able to work with different table prefixes.

    Only when you do it the right way when you install it.

    If you restore access to the one your trying to change you can use this plugin.

  8. guice
    Member
    Posted 6 years ago #

    But wait a second...there is no "right way" when changing table prefixes. All you do is rename all your tables, and then edit the "$table_prefix" variable.

    WP should not use that value within its WP database. It's for locating the tables, only. Well, that's what it's suppose to be. The 'wp_' within the DB should only be namespacing reasons (so it doesn't conflict with plugins).

    This is a major flaw, in my book, within WP. It completely makes it improvable to move away from the wp_ table prefix for anybody with automated installed (think Fantastico). Huge problem.

    However, thank you very much for the plugin file. Using it's source, I was able to determine the one row I missed within (delu|goma)_options with the option_name of 'wp_user_roles'. Updating that row fixed it.

    Is there anyway to fix WP? This, imho, is a big problem. It makes it improvable for anybody to switching from wp_ prefix.

  9. Jeremy Clark
    Moderator
    Posted 6 years ago #

    You can go here and submit the idea. Or you can go here and submit it as a bug.

  10. Beer
    Member
    Posted 6 years ago #

    A few SQL queries to help?

    'new_' is the new table prefix
    'old_' is the old table prefix

    UPDATE new_usermeta
    SET meta_key = REPLACE(meta_key,'old_','new_');

    UPDATE new_options
    SET option_name = REPLACE(option_name,'old_','new_');

Topic Closed

This topic has been closed to new replies.

About this Topic