December 22, 200817 yr Hi all, I have just exported a database into a .csv file and have since deleted everything in my data base. Now I tried to import the .csv file back to restore the database and it is giving me this error! Exporting and importing is done through phpmyadmin. MySql version is 5.0.45. I have tried to import using both utf-8 and latin1 char set but both give me the same error. I have tried importing using ANSI compatibility mode but same error as well. Please provide some help as the file contains all my customers details! SQL query: & quot; MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"' at line 1
December 22, 200817 yr It would help if you could also give line 1 of the SQL statement that PHPMyAdmin is trying to execute (you can retrieve it via the web interface), and perhaps the line of the CSV which is causing the problem.
December 22, 200817 yr Author It would help if you could also give line 1 of the SQL statement that PHPMyAdmin is trying to execute (you can retrieve it via the web interface), and perhaps the line of the CSV which is causing the problem. Have sent you a PM.
December 22, 200817 yr Try these steps (from a quick Google search---I haven't done this myself). Make at least one backup of your file if the data is that critical, just in case something happens to it!!
December 22, 200817 yr Author Try these steps (from a quick Google search---I haven't done this myself). Make at least one backup of your file if the data is that critical, just in case something happens to it!! Thanks for your help! It seems that my phpmyadmin doesn't have importing as CSV as an option, only SQL. But I was able to export via CSV. How do I allow phpmyadmin to allow me to import CSV? Thanks again, really.
December 22, 200817 yr BTW, I think what you might be missing is that you haven't created the database tables first... CSV doesn't export the database schema and table structures. So you need to create all the tables with the right fields first, then import your CSV file into the individual tables. In phpMyAdmin: choose the database + table first, then choose Import. You will now have a CSV option on the import page.
December 22, 200817 yr Author BTW, I think what you might be missing is that you haven't created the database tables first... CSV doesn't export the database schema and table structures. So you need to create all the tables with the right fields first, then import your CSV file into the individual tables. In phpMyAdmin: choose the database + table first, then choose Import. You will now have a CSV option on the import page. Oh no, my database is totally empty without any tables as I have deleted all of them accidentally. I can't recall the table names now either. I exported it via CSV because that was the option selected for me. So that is now no chances of saving it anymore?
December 22, 200817 yr Well there is a chance... you need to work out what the database table structure was and restore it manually, then import the data back. Table and field names don't matter, for the purposes of importing your CSV data at least, but the number and type of columns in each table do. Read your CSV file in a plain text editor; each line is a new row in a table. You'll see how many fields are required, and probably what type they were. Unfortunately it doesn't tell you where one table ends and another begins, so you'll have to work it out from the data itself. Then create tables (called A, B, C etc. for now, so they are in the correct order) with the correct number and type of fields, and finally import your data into each one. Then you'll have to view whatever code uses those tables and restore the table and field names manually. I can't think of any other way to do it. You should have exported the data as SQL, zipped if necessary, and not CSV. The data is safe, but the structure is lost... probably better that way around though
Create an account or sign in to comment