I had to copy over a wordpress database from production to my local server.
Export seemed ok, about 400+ mB but there would be errors upon importing in my local.
I kept getting the ERROR 1064 (42000) at line xxx: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near: ‘[extract from the SQL code]’.
The line number given seemed a bit off. I couldn’t find any typo or command that needed retyping. I tried to check the versions of MariaDB, and tried to export the file several times in different formats to check compatibility (MySQL40, MySQL343, etc).
Then I delved into the sql file and realized that:
- the header was repeated partially at the very bottom
- where the header started repeated, the previous SQL instruction was truncated.
So back to the export settings: I did two things and the result worked:
- first, I double-checked and realized about 50 tables from the 250 weren’t checked, even though I had selected “Check all” on the tables page before clicking the “Export” tab. Turns out it only checks those printed on the page, so change your view settings to list them all. To modify how may tables are displayed in phpMyAdmin, follow these steps.
- then, to clear my suspicion, I extended the maximum query length from 50,000 to 500,000.
Sometimes your connection is too slow, and / the database is so large that exports are only partial and interrupted. Often, there’s no error message, so you have to check differences manually at times (checking how many records are in each table is often enough).
If this is the case, a long workaround is to first export the database structure, without the data. Then, copy the tables one by one or several at a time. If you export both data and structure for the tables, you have to drop it first before re-importing it. If you only import the data, then you don’t have to drop the table, but know that it will append data – if your table isn’t empty, you might get duplicate records.
For truly large tables, you can also do the same: load the table without data, and then export rows one batch at a time. Take note of the start row and how many you want to export. Then, import the partial backups one after the other until your row count matches.
It’s surely quicker to work through mysqldump because phpMyAdmin isn’t made for large databases (…), but if you don’t know which login to use, you at least have this workaround.