Tuesday 13 December 2011

Invalid field count in csv input on line 1

I came across this annoying phpmyadmin 'feature' when trying to import some data to a newly created MySQL table. I had a CSV file full of data. The columns matched the number of fields but I kept getting the error 'Invalid field count in csv input on line 1'.

The problem was, that the 'Fields terminated by' field in the import screen was set to ';' instead of a ','. By resetting this field, everything worked.

Monday 5 December 2011

Reset the Index of a MySQL table

Sometimes, I will be playing about with a MySQL database, often at the start of an application. I'll fire a load of dummy data in and test. When I've finally done with this phase I'm ready to start from the beginning. I might have an ID field which I'd like to auto increment but this time starting from 0. To reset this field, first empty all the records in the table, then you can apply a line like this:
ALTER TABLE `mytable` AUTO_INCREMENT=0