【发布时间】:2013-12-19 20:10:58
【问题描述】:
为了使用 MAMP 将 120Mb 数据库导入 phpMyAdmin,我使用以下方法将其拆分:
split -l 100 /Applications/MAMP/htdocs/test/database_test_wordpress.sql /Applications/MAMP/htdocs/test/dbpart-
但是在导入第二部分时出现错误:
Error
SQL query:
CREATE TABLE `wp_comments` (
`comment_ID` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
`comment_post_ID` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT '0',
`comment_author` TINYTEXT NOT NULL ,
`comment_author_email` VARCHAR( 100 ) NOT NULL DEFAULT '',
`comment_author_url` VARCHAR( 200 ) NOT NULL DEFAULT '',
`comment_author_IP` VARCHAR( 100 ) NOT NULL DEFAULT '',
`comment_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`comment_date_gmt` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`comment_content` TEXT NOT NULL ,
`comment_karma` INT( 11 ) NOT NULL DEFAULT '0',
`comment_approved` VARCHAR( 20 ) NOT NULL DEFAULT '1',
`comment_agent` VARCHAR( 255 ) NOT NULL DEFAULT '',
`comment_type` VARCHAR( 20 ) NOT NULL DEFAULT '',
`comment_parent` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT '0',
`user_id` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY ( `comment_ID` ) ,
KEY `comment_post_ID` ( `comment_post_ID` ) ,
MySQL said: Documentation
#1064 - 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 '' at line 18
我需要以某种方式升级数据库吗?还是我走远了?!抱歉,新手 :-)
注意:我首先尝试在 MAMP 的 php.ini 中增加 upload_max_filesize、memory_limit 和 post_max_size,但在导入时出现 MySQL server has gone away 错误。
【问题讨论】:
-
您不能将包含跨越多行的 SQL 命令的文件“随机”拆分为 x 行,并且仍然希望它能够工作……
-
尝试使用php导入sql文件,先读取文件
file_get_contents,再读取mysql_query。这样就不用拆分sql文件了。
标签: mysql linux phpmyadmin mamp