将实时站点迁移到本地主机时出现数据库连接问题

时间:2017-01-18 作者:chow

在这里我的头撞了几天墙。我有一个多站点实时安装,正在尝试将其下拉到网络上的本地主机,因为该站点不活动,我想保留它。localhost 是一个运行16.04的linux机箱,具有:

  • php Version 5.6.29-1+deb.sury.org~xenial+1
  • apache2 2.4.18
  • mySQL 14.14 Distrib 5.7.16
实时服务器正在运行:-php Version 5.4.29 - mySQL 14.14 Distrib 5.5.52 - 我不知道如何找出apache 正在live server上运行。

以下是我为迁移所做的工作:

mySQL 数据库通过cPanelmySQL, apache2, 等打开localhostmySQL 在…上localhost将我的live站点中的每个文件复制到localhost/etc/hosts 到点127.0.0.1 yyz.com 维护当前站点上的子域

  • chgrp 允许www-data 对本地主机上的文件夹和文件进行组访问
  • chmod 775 在localhost的文件夹和文件上,可以确认localhost正在服务htmlphp 文件wp_*_options siteurl 指向yyz.comphp并返回正确的表计数。我用一个.php 文件送达时间yyz.com (yyz.com/sql.php)DB_NAME, DB_USER, DB_PASSWORDDB_HOST 在里面wp-config.php 以反映具有适当访问权限的用户帐户.htaccess 在…上localhostyyz.com 或localhost127.0.0.1 我得到:

    Error establishing a database connection

    如果我去yyz.com/wp-admin/localhost/wp-admin/127.0.0.1/wp-admin/ 我得到:

    One or more database tables are unavailable. The database may need to be repaired.

    如果我尝试修复数据库,我会遇到许多错误,而如果我在live site上修复数据库,我不会遇到这些错误:

    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'siteurl\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'active_plugins\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'hack_file\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'blog_charset\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'permalink_structure\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'wp_user_roles\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'template\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'stylesheet\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'category_base\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'tag_base\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'link_manager_enabled\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'sidebars_widgets\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_pages\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_calendar\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_archives\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_links\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_meta\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_search\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_text\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_categories\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_recent-posts\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_recent_entries\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_recent-comments\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_recent_comments\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_rss\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_tag_cloud\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'widget_nav_menu\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'use_smilies\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'cron\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES (\'cron\', \'a:2:{i:1484715804;a:1:{s:16:\\"wp_version_check\\";a:1:{s:32:\\"40cd750bba9870f18aada2478b24840a\\";a:3:{s:8:\\"schedule\\";s:10:\\"twicedaily\\";s:4:\\"args\\";a:0:{}s:8:\\"interval\\";i:43200;}}}s:7:\\"version\\";i:2;}\', \'yes\') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES (\'cron\', \'a:2:{i:1484715804;a:1:{s:17:\\"wp_update_plugins\\";a:1:{s:32:\\"40cd750bba9870f18aada2478b24840a\\";a:3:{s:8:\\"schedule\\";s:10:\\"twicedaily\\";s:4:\\"args\\";a:0:{}s:8:\\"interval\\";i:43200;}}}s:7:\\"version\\";i:2;}\', \'yes\') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES (\'cron\', \'a:2:{i:1484715804;a:1:{s:16:\\"wp_update_themes\\";a:1:{s:32:\\"40cd750bba9870f18aada2478b24840a\\";a:3:{s:8:\\"schedule\\";s:10:\\"twicedaily\\";s:4:\\"args\\";a:0:{}s:8:\\"interval\\";i:43200;}}}s:7:\\"version\\";i:2;}\', \'yes\') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'timezone_string\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'gmt_offset\' LIMIT 1
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES (\'cron\', \'a:2:{i:1484768340;a:1:{s:20:\\"wp_maybe_auto_update\\";a:1:{s:32:\\"40cd750bba9870f18aada2478b24840a\\";a:3:{s:8:\\"schedule\\";s:10:\\"twicedaily\\";s:4:\\"args\\";a:0:{}s:8:\\"interval\\";i:43200;}}}s:7:\\"version\\";i:2;}\', \'yes\') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)
    
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'theme_switched\' LIMIT 1
    
    
    ( ! ) Warning: Cannot modify header information - headers already sent by (output started at /home/yyz/Applications/yyz/wp-includes/wp-db.php:1220) in /home/yyz/Applications/yyz/wp-admin/maint/repair.php on line 12
    Call Stack
    #   Time    Memory  Function    Location
    1   0.0001  230104  {main}( )   .../repair.php:0
    2   0.0289  1714280 header ( )  .../repair.php:12
    WordPress database error: [Table \'yyz.wp_options\' doesn\'t exist]
    SELECT option_value FROM wp_options WHERE option_name = \'html_type\' LIMIT 1
    
    在这一点上感到困惑和沮丧。非常感谢您的帮助。可能是版本差异mySQLPHP? 如果不是不可能的话,我很难在localhost, 因为它正在使用mySQL 对于其他应用程序也是如此。

  • 1 个回复
    SO网友:Ravi Shinde

    您是否考虑过像All-in-one wp迁移一样使用迁移插件-https://wordpress.org/plugins/all-in-one-wp-migration/

    它可以处理盒子里的所有东西。

    相关推荐

    无法上载主题。错误:“无法将上载的文件移动到/var/www/wp-ploads/localhost/2011/10。”

    The uploaded file could not be moved to /var/www/wp-uploads/localhost/2011/10. 这是我尝试上载wordpress主题时收到的错误消息。这是我的文件夹的当前权限状态。$ sudo ls -la /var/www/wp-uploads/localhost total 12 drwxrwxr-- 3 root www-data 4096 2011-10-27 16:44 . drwxr-x--