Home > Software engineering >  Restoring WordPress site only from htdocs's webstie folder
Restoring WordPress site only from htdocs's webstie folder

Time:01-26

I had a wordpress site hosted on localhost using xampp.

Due to unexpected problems only what I've got from my old XAMPP files is htdocs's folder of mentioned site. Is there a way to restore the old website only from this file only?

CodePudding user response:

WordPress content is stored in the database. If you don't have your MySQL database exported (.sql file extension) from phpMyAdmin (web) or mysqldump (CLI), you'll have files without content, and likely a lot of PHP errors. The database also has the configuration for which theme to use, which plug-in(s) to enable, your Dashboard login (and users), etc.

If you have command line access to your MySQL database, you can use the following command to get a copy of your database:

mysqldump --add-drop-table -u USERNAME -p DBNAME > DBNAME.sql

This assumes the hostname is "localhost", but you can specify the hostname with -h HOSTNAME.

--add-drop-table is not required, but helpful if you're wanting to start clean with a database import. Keep in mind that it will delete the table in its entirety, so if you've already got a live site using the same database and table prefix, you're wiping out that live site.

-p will prompt you for the password once connected to the MySQL server. If successful, there won't be any output as the database is exported into the filename you provided.

You can name the output file anything you want, but it's a good idea to keep it the same name of your database, or even SITE_database.sql (i.e.: mysite.com_database.sql).

However, if you have the export of your MySQL database, you can import it with the following command:

mysql -u USER -p DBNAME < DBNAME.sql

Similarly, you'll be prompted for the password, and if no errors on the command prompt, the import should have been successful. With your site content and MySQL database restored, your site should appear as it was, content and all.

  • Related