我正在尝试将.bz2文件导入MySql数据库,但我收到此错误:
Fatal error: Out of memory (allocated 386400256) (tried to allocate 378535937 bytes) in C:\wamp\apps\phpmyadmin4.6.4\libraries\plugins\import\ImportXml.php on line 90
我在这里尝试了很多解决方案,包括提出upload_max_filesize
,memory_limit
和post_max_size
任何帮助都会非常感激!
答案 0 :(得分:1)
如果可以的话,直接使用MySQL而不使用PHP:
wget http://dumps.wikimedia.org/enwiki/latest/enwiki-latest-page.sql.gz
wget http://dumps.wikimedia.org/enwiki/latest/enwiki-latest-category.sql.gz
wget http://dumps.wikimedia.org/enwiki/latest/enwiki-latest-categorylinks.sql.gz
wget http://dumps.wikimedia.org/enwiki/latest/enwiki-latest-redirect.sql.gz
wget http://dumps.wikimedia.org/enwiki/latest/enwiki-latest-pagelinks.sql.gz
wget http://dumps.wikimedia.org/enwiki/latest/enwiki-latest-langlinks.sql.gz
gzip -d enwiki-latest-page.sql.gz
gzip -d enwiki-latest-category.sql.gz
gzip -d enwiki-latest-categorylinks.sql.gz
gzip -d enwiki-latest-redirect.sql.gz
gzip -d enwiki-latest-pagelinks.sql.gz
gzip -d enwiki-latest-langlinks.sql.gz
# Don't need this if MySQL is configured correctly.
# SET GLOBAL innodb_file_per_table = 1;
# SET GLOBAL general_log = 'OFF';
# SET FOREIGN_KEY_CHECKS=1;
# SET GLOBAL character_set_server = utf8mb4;
# SET NAMES utf8mb4;
CREATE DATABASE wiki_en; USE wiki_en;
# Don't need this if MySQL is configured correctly.
# ALTER DATABASE wiki_en CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
mysql -u root -p wiki_en < enwiki-latest-page.sql
mysql -u root -p wiki_en < enwiki-latest-redirect.sql
mysql -u root -p wiki_en < enwiki-latest-category.sql
mysql -u root -p wiki_en < enwiki-latest-categorylinks.sql
mysql -u root -p wiki_en < enwiki-latest-pagelinks.sql
mysql -u root -p wiki_en < enwiki-latest-langlinks.sql
# Indicative filesizes:
# -rw-r--r-- 1 root root 35G Jun 2 07:01 enwiki-latest-pagelinks.sql
# -rw-r--r-- 1 root root 13G Jun 2 07:45 enwiki-latest-categorylinks.sql
# -rw-r--r-- 1 root root 4.3G Jun 2 11:08 enwiki-latest-page.sql
# -rw-r--r-- 1 root root 900M Jun 2 11:03 enwiki-latest-langlinks.sql
# -rw-r--r-- 1 root root 378M Jun 2 11:10 enwiki-latest-redirect.sql
# -rw-r--r-- 1 root root 117M Jun 2 11:03 enwiki-latest-category.sql
如果你真的必须使用PHP,你需要设置PHPMyAdmin的内存限制(参见this answer),并确保你已经运行了MySQL。