I am going to write this short entry as a personal reminder, as this is the second time this has happened to me, although I solved it quickly, I had to deal with the same problem again.
A few days ago, making changes in a WordPress installation, among the various changes made, I changed the prefixes of the WordPress tables, those that by default come as
wp_directly from phpMyAdmin.
Well, the thing is that after the corresponding change in the file
wp-config.php, in the variable
$table_prefix, I tried to enter and it took me directly to the home page, without giving me any error.
I tried clearing cache (the usual culprit, poor thing), creating a new administrator user with the file trick at
mu-plugins… and nothing, and lo and behold, after a few tests I remembered what had already happened to me a year or two ago.
The “problem” is that the database stores user information with the full name of the table and if we rename the prefix we will be changing the name of the table.
I think a better approach to this problem would be to save the table name without the prefix, since we have it from WordPress itself, making it easier to rename tables without having to search in the stored contents.
If you want to make the prefix change, you have the easy option of a plugin that does it or do it by hand as I have done, but remembering after making such replacements, with two
UPDATE sentences from
SQL is enough:
UPDATE miprefijowp_options SET option_name = 'miprefijowp_user_roles' WHERE option_name = 'wp_user_roles'; // 1 registro UPDATE miprefijowp_usermeta SET meta_key = REPLACE( meta_key , 'wp_', 'miprefijowp_' ); // 6 registros aprox.