“Re-initializing” a wordpress website on localhost
-
Hi, I have been running a WP website on my computer (using XAMPP) and just had a few problems, so I have had to re-install XAMPP and then I copied over the MySql files and WordPress files from the earlier installation.
Now, when I go to open the site in a browser, which is just a localhost, WP wants to do a new install and falls over when it finds many of the files already in existence (“wordpress database error”)! It’s an unusual circumstance, but is there any way for me to save my existing site and all the work that I have put into it? cheers, BruceThe page I need help with: [log in to see the link]
-
Hello,
If you have copied everything ( including a correct wp-config.php pointing to a database ) file then WordPress shouldn’t be giving you an install option. It would instead inform you that it can’t connect to the database as an error if there was something wrong with MySQL.
By showing an installation screen it usually means there’s no wp-config configured inside the base installation folder. Are you 100% sure you have copied everything correctly ?
If there is no
wp-config.phpyou can duplicate and rename thewp-config-sample.phpfile towp-config.phpand edit it to alter the database information to connect with your new server credentials.Hi Xenos, I should check the files that I need to copy over in that case. I will keep working on it and let you know what happens. Many thanks
Just checked and there is a config file and all looks to be ok with the contents. It still comes up and tries to install a new copy. I wonder if there is a file that I need to copy but haven’t? I have done all of the WordPress directory plus mysql..
A full copy of your WordPress installation folder and the database ( usually sql export / import instead of copying the mysql folder ) is fine and you should be up and running ( at least not giving any major issues like a re-install ).
Make sure that your WordPress folder also has read/write access ( for example if you are on Windows don’t have it marked as read-only ). I’m not sure how your server / system is set up to assist with permissions.
You can also read the codex just in cased you missed a step at https://codex.ww.wp.xz.cn/Moving_WordPress .
I copied over the MySql files…
You may be able to copy the MySQL file in XAMPP, but it’s probably best to export/import using phpMyAdmin. Are you able to see the WordPress tables in phpMyAdmin?
ah! I am looking at that now. I need to learn more about MySql!!! I see the import option but it seems to want just a single file and I have no idea which one! I thought the database might have been a series of files.
There might be a delay before I can respond again!!! 11pm over here!Hi again,
I am looking for the sql database to import as per the above discussion and it is not there! I am assuming that the file I need is a .sql and it’s name should be the actual db name. All that I can find is a directory with that name and none of the files in there are .sql, only .frm and .ibd
Do I import each of these files?? The directory is under MySql/data/….
Many thanks for persevering with this!!!Ok, progress … I zipped the db files and imported them to the new setup. One thing – do I only zip the files under the directory with the db name or do I go one up and zip everything in the data directory? (Some big files in that data directory).
I have moved the WP files across in their entirety.
I am getting a message now “error establishing a database connection”. However, first I need to check on that first issue – how much do I zip and import?
Moving ahead at breakneck speed!!! 🙂
Ok let me explain something since you are new to this for future reference and to avoid confusion.
The .sql file is generated when you export a database and that is the safest ( and most common ) way to move a database or keep a backup of it. In your case to get an .sql file the idea was to go into phpMyAdmin on your ‘old’ server select the database and click Export to give you that file. After that you could Import it into any other server.
An .SQL file is a simple text file that includes all the SQL commands needed + data to re-create your database.
—
If you could simply copy the database then as soon as you copied the database directory in your new data folder it should be showing that database up on your phpMyAdmin page as well.
—
Now to the problem at hand I don’t think you can re-create a database only from the .frm / .ibd files, there are more files needed to copy folder as far as I know for example the
ibdatathat are located under/data/folder etc.If you have a full copy of your old XAMPP then there is a chance. If you only have your database folder copied I’m not entirely sure that there’s a way to restore the database ( not 100% but I’ve never done it at least ).
Hi Xenos, thanks for the explanation. Yes, I do have a full copy of the original files. The problem I have, is that I can go into phpMyAdmin and go to export, then I can browse to those original files, but there is no .sql there and I can’t run the original files under localhost, so I can’t open them in phpMyAdmin and do an export.
I tried creating a db in phpMyAdmin and then I zipped the files and imported them into the new db (with same name as the original) but when I run the website in the browser, it is giving me a blank WP project and so is not picking up the database. So I think that’s my main problem. I need to see if I can create a sql file for the original db.
If I could run the original installation, I could export the db and all would be ok.In that last post I should have said…I can go into phpMyAdmin and go to IMPORT (not export), but I can then only browse to the existing files which do not include a .sql file. I hope that makes sense!
That won’t work, that’s what I explained 🙂 you can only
importan SQL file that has to be exported from your previous server. You had to manually export it before shutting down the old server.Let’s try this though since you have all of your files!! :
1] Stop the MySQL service from xampp
2] Go into your
current xampp/mysqlfolder andmovebothdataandbackupfolders somewhere safe to keep them as a backup ( even though there are no databases yet ).3] Go to your
old serverfiles and under/xampp/mysql/COPYthe foldersdataandbackupinto your new server setup.4] Start your MySQL service and enter phpMyAdmin again.
You should be able to see all the databases you had on your old server and access them properly.
Tell me if that way helps !
Again it is not the normal way of copying / moving databases but in your case it’s the only thing that could work.
Yes!!! That worked!!! I had to do a few refreshes and then away it went!!! So all done! Thanks so much for that. I don’t think I could have done that without your help.
It gives me some appreciation for what I will need to do when I move it to be live!!! But I might try out a plugin for that!!! Actually, now that I can get to the db in phpMyAdmin, I can export it in the correct manner….
Thanks again for all your help! BruceI’m glad we sorted it out and that was thanks to you for keeping all the files ( not many users do that ). Yes it would be best to either export the database next time or use a backup ( migration ) plugin as you mention to be sure & safe.
The topic ‘“Re-initializing” a wordpress website on localhost’ is closed to new replies.