简体   繁体   English

从 phpMyAdmin 导出非常大的表?

[英]Exporting very large tables from phpMyAdmin?

By very large tables, I mean tables with 5 million to 20 million records or even larger.非常大的表是指包含 500 万到 2000 万条记录甚至更大的表。 I need to export them into MS Excel in multiple files, each of which will be 60,000 records.我需要将它们以多个文件的形式导出到 MS Excel 中,每个文件将有 60,000 条记录。

It would be a manual chore to export them one by one, you know by entering Dump xxxx row(s) starting at record # xxxx and hitting Go a couple hundred times.将它们一个一个地导出将是一项手动繁琐的工作,您可以通过从记录 # xxxx 开始输入 Dump xxxx 行并点击 Go 数百次来了解。 Very annoying.很烦人。

Is there any way to automate this process?有没有办法自动化这个过程?

What I have tried thus far:到目前为止我尝试过的:

  1. Add " print_r($_POST);exit(); " at the top of phpmyadmin/export.php to see what variables have been passed when I'm exporting the table into Excel.phpmyadmin/export.php的顶部添加“ print_r($_POST);exit(); ”以查看当我将表导出到 Excel 时传递了哪些变量。 Remove them and then use cURL to post the same variables to phpmyadmin/export.php from my own php script.删除它们,然后使用 cURL 将相同的变量从我自己的 php 脚本发布到 phpmyadmin/export.php。 This way, I can make it automated in saving the exported data and increasing starting record #.这样,我可以自动保存导出的数据并增加起始记录#。 However, phpmyadmin/export.php keeps giving me this error when I'm posting all the vars to it:但是,当我将所有变量发布到它时, phpmyadmin/export.php不断给我这个错误:

    export.php: Missing parameter: what (FAQ 2.8) export.php:缺少参数:什么(FAQ 2.8)

    export.php: Missing parameter: export_type (FAQ 2.8) export.php:缺少参数:export_type(FAQ 2.8)

Which is weird because I'm 100% sure that 'what' and 'export_type' are in the posted variables.这很奇怪,因为我 100% 确定 'what' 和 'export_type' 在发布的变量中。 Tried everything in (FAQ 2.8) but nothing worked neither.尝试了(FAQ 2.8)中的所有内容,但没有任何效果。

  1. Firefox iMacros add-on. Firefox iMacros 插件。 Gave it a try but it doesn't seem to be able to automatically increase an form input value by a certain amount.试一试,但它似乎无法自动将表单输入值增加一定数量。 Or does it?或者是吗?

Any idea how I can achieve this?知道我如何实现这一目标吗? There ain't any native support in exporting mysql into excel right?将 mysql 导出到 excel 中没有任何本机支持吗?

Update: My client wants it.更新:我的客户想要它。 Not me.不是我。 He's just obsessed with Excel and does everything with it.他只是沉迷于 Excel 并用它做所有事情。

尝试使用桌面应用程序mySQL YOG

That size?!这么大?!
You do not use a web-server to do that (time-limit is just one of the cones of that), you need a command-line/exe/desktop application to handle such sizes.你不使用网络服务器来做到这一点(时间限制只是其中的一个),你需要一个命令行/exe/桌面应用程序来处理这样的大小。
In php it wouldn't be too hard to write such a thing using the php-cli, and it should be done that way.在 php 中,使用 php-cli 编写这样的东西不会太难,应该这样做。
Bottom line: no web tool should do that.底线:没有网络工具应该这样做。

使用MySQL命令行工具导出为CSV,然后使用GNU split每65k行左右分割一次。

SELECT fields INTO OUTFILE 'export.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\' LINES TERMINATED BY '\n' FROM tablename;

Execute below mysql query:执行以下 mysql 查询:

SELECT 
    name,mobile,email,address
FROM
    customer
WHERE
  status = 'Active' 
INTO OUTFILE 'C:/tmp/active_customers.csv' 
FIELDS ENCLOSED BY '"' 
TERMINATED BY ';' 
ESCAPED BY '"' 
LINES TERMINATED BY '\r\n';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM