Maybe this title sounds a little strange to you, but what happened to me is the following.
The Situation
I transfer a website from one hosting to a different one, everything has been fine and when I go to look at the new site it turns out that the web is very different from how it should be, the texts are different, there are other sections. In short, it’s a different website than the one I’ve been to.
The fact is that this had already happened to me on a previous occasion. When you see a different website, the first impression is one of surprise, then you realize the problem and it is solved in a minute. That’s why I want to write this short entry so that I am documented for the third time, which will surely happen with my memory of Dory.
The transfer process
There are many ways to transfer a website from one hosting to another, either via plugins, from ManageWP, with the GridPane options, via WP CLI or directly by hand transfer. I will try to write about the different systems I use, depending on the website to be transferred, in a future post.
The first thing I did, was to create a new WordPress site on the target hosting using the hosting installer. Then I transferred a zip file with the contents of the folder wp-content
and from WP CLI I imported the previous database: wp db import database-previous.sql
The file wp-config.php
being a new WordPress installation already has the correct database data, but what needs to be changed is the database prefix.
So, the first thing I did was to open phpMyAdmin to look at the database prefix and then change it in the variable $table_prefix
and put the new one I had just seen in phpMyAdmin.
And here comes the problem, as soon as I see the new website from the browser, the texts, appearance, photos, menus, etc. do not match. It is a website that deals with the same subject but with totally different contents.
The solution
After the first few minutes of strangeness, I immediately realized the problem, which, as I said, had already happened to me before.
With a quick glance at the database, I see that there is not a single table prefix, but in this case there are three. The prefix of the new installation that I just made, the prefix that I copied in the file wp-config.php
and one more prefix, which is the one that corresponds to the actual installation of this WordPress.
By changing the prefix in the wp-config.php
to this third prefix, everything works correctly again and we have again the web we wanted to transfer.
What we must do now is to delete all the tables with the new prefix, that is, from the WordPress that we just installed for the transfer with practically empty tables. Because if not, the same thing will happen again and we will have more and more prefixes and more and more different appearances and contents.
The prefix that I had written before, corresponds to this same web site in a previous version and when it was migrated to an egg hosting or the change of web was made, when using new prefixes for the tables the previous ones were not eliminated, so all these tables were not being used, but they were still in the database.
The best thing to do is to make a copy of the complete database in case we need this previous version at some point and as soon as we have the copy, delete all these tables from the previous version.
Conclusion
As you can see, once the initial scare has passed, changing from one table prefix to another is a matter of a few seconds and we already have a totally different website with the only modification of a variable, since we are actually moving from one WordPress table to another totally different one.
I hope that if this has ever happened to anyone, you may find this little trick/clarification useful. A silly thing to write, but when it happens to you, the first impression is “What happened here”.