简体   繁体   English

仅从 htdocs 的 webstie 文件夹恢复 WordPress 站点

[英]Restoring WordPress site only from htdocs's webstie folder

I had a wordpress site hosted on localhost using xampp.我使用 xampp 在本地主机上托管了一个 wordpress 站点。

Due to unexpected problems only what I've got from my old XAMPP files is htdocs's folder of mentioned site.由于意外问题,只有我从旧的 XAMPP 文件中得到的是提到站点的 htdocs 文件夹。 Is there a way to restore the old website only from this file only?有没有办法只从这个文件恢复旧网站?

WordPress content is stored in the database. WordPress 内容存储在数据库中。 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.如果您没有从 phpMyAdmin (web) 或 mysqldump (CLI) 导出 MySQL 数据库(.sql 文件扩展名),您将得到没有内容的文件,并且可能会出现很多 PHP 错误。 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:如果您可以通过命令行访问 MySQL 数据库,则可以使用以下命令获取数据库的副本:

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 .这假定主机名是“localhost”,但您可以使用-h HOSTNAME指定主机名。

--add-drop-table is not required, but helpful if you're wanting to start clean with a database import. --add-drop-table不是必需的,但如果您想通过数据库导入开始清理,它会很有帮助。 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. -p将在连接到 MySQL 服务器后提示您输入密码。 If successful, there won't be any output as the database is exported into the filename you provided.如果成功,将不会有任何 output,因为数据库已导出到您提供的文件名中。

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 (ie: mysite.com_database.sql).您可以随意命名 output 文件,但最好将其与您的数据库名称保持一致,甚至是 SITE_database.sql(即:mysite.com_database.sql)。

However, if you have the export of your MySQL database, you can import it with the following command:但是,如果您导出了 MySQL 数据库,则可以使用以下命令导入它:

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.恢复您的站点内容和 MySQL 数据库后,您的站点应该显示出原来的内容和所有内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM