gpt4 book ai didi

php - 将 WordPress 数据库迁移到主机,无需外部 mysql 访问

转载 作者:行者123 更新时间:2023-11-29 14:37:42 26 4
gpt4 key购买 nike

我正在尝试将大量网站迁移到不提供对 mysql 数据库的外部访问的新主机。

我已经从原始主机导出了一个备份,其中包括以下样式的 mysql 备份:

-- MySQL dump 10.11
--
-- Host: localhost Database: blueball_wrdp1
-- ------------------------------------------------------
-- Server version 5.0.92-community

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `wp_commentmeta`
--

DROP TABLE IF EXISTS `wp_commentmeta`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL auto_increment,
`comment_id` bigint(20) unsigned NOT NULL default '0',
`meta_key` varchar(255) default NULL,
`meta_value` longtext,
PRIMARY KEY (`meta_id`),
KEY `comment_id` (`comment_id`),
KEY `meta_key` (`meta_key`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

我正在尝试将其导入新主机,该主机创建了一个同名的数据库。我能想到的最简单的方法是使用 php,如下所示:

<?php

$con = mysql_connect('account.host.com', 'account_wrdp1', '1234567890');

if (!$con){
die('Could not connect: ' . mysql_error());
}

mysql_select_db("account_wrdp1", $con);

if (mysql_query( file_get_contents('account_wrdp1.sql') ,$con)){
echo "Tables created and populated.";
} else {
echo "Error populating database: " . mysql_error();
}

mysql_close($con);

?>

但是当我这样做时,我收到错误:

Error creating database: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL auto_in' at line 25

注意起初,我遇到了像 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 这样的元行错误,所以我用 sed 将它们全部删除,这就是我看到这个新错误的时候.

所以我的问题是,为什么看似良好的 MySQL 转储会产生错误?

有没有一种更简单的方法可以让我解决整个问题 - mysql 服务器似乎是一个独立的虚拟服务器,与我的网站托管的服务器不同,而且我绝对没有 shell 访问权限等...

最佳答案

假设您有 FTP 访问权限,那么上传 PHPMyAdmin 的副本并使用它来导入文件不是最简单的吗?它可能会或可能不会修复您遇到的错误,但它会使导入过程变得更加容易。

关于php - 将 WordPress 数据库迁移到主机,无需外部 mysql 访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8658407/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com