How to export millions of rows from MySQL to CSV via PHP without exhausting memory?
So I have this table: mysql> DESCRIBE table; +-------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+------------------+------+-----+---------+----------------+ | id | int(15) unsigned | NO | PRI | NULL | auto_increment | | unid | char(9) | NO | UNI | NULL | | | rs | varchar(255) | NO | | NULL | | +-------+------------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec) Which contains millions of rows: mysql> SELECT COUNT(1) FROM table; +----------+ | COUNT(1) | +----------+ | 9435361 | +----------+ 1 row