MySQL General error: 126 Incorrect key file for table '/tmp/#sql_27e6_0.MYI'; try to repair it' I have a table in MySQL with ~2,000,000 rows.

When I try to select all records, it exhausts the system's memory and I get an error about memory exhaustion back.

When I try to use the MySQL LIMIT and select 1,000 records, the error in the title is returned:

General error: 126 Incorrect key file for table '/tmp/#sql_27e6_0.MYI'; try to repair it'

What's the best course of action to export all of the data in this table?  Why is it returning an error when only trying to pick 1,000 records?

My query:

select * from notes order by id asc limit 1000
You can remove any /tmp/#sql* files -- they are tmp tables left over after a crash.  Or they are part of something (ALTER, CREATE, etc) that is going on, but stuck waiting for disk space.

It is often a mistake to have a separate filesystem for tmp -- you run into problems like this:  Plenty of space to finish a task, but not in /tmp.  Consider changing mysql's tmpdir setting.