我正嘗試將大量網站遷移到不提供外部訪問mysql數據庫的新主機。將wordpress數據庫遷移到沒有外部mysql訪問的主機
-- MySQL dump 10.11
--
-- Host: localhost Database: blueball_wrdp1
-- ------------------------------------------------------
-- Server version 5.0.92-community
/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @[email protected]@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @[email protected]@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @[email protected]@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 */;
我試圖將其導入到新的主機,它創造了一個同名的數據庫:
我從源主機,其中包括在這種風格的一個MySQL備份導出的備份。我能想到這樣做最簡單的方法是用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 @[email protected]@CHARACTER_SET_CLIENT */;
這樣的meta行時遇到了錯誤,所以我用sed全部解決了這些錯誤,這是我看到這個新錯誤時的情況。
所以我的問題是,爲什麼看起來不錯的MySQL轉儲創建一個錯誤?
是否有更簡單的方法來處理整個問題 - 因爲mysql服務器似乎是一個獨立的虛擬服務器,而我的網站託管在這個虛擬服務器上,而且我絕對沒有shell訪問等。
你知道你的新主機正在運行的MySQL版本? – jprofitt 2011-12-28 16:32:56
我認爲它是:5.1.56 – 2011-12-28 17:20:33