SQL syntax error when importing WordPress Database file - mysql

I'm trying to move my wordpress site to a new server. I exported my old database to a .zip .sql file using phpMyAdmin
When I try to import the database file on my new server I get this error:
Error
SQL query:
INSERT INTO wp_options VALUES (186159, '_transient_wc_var_prices_575', '{"f9e544f77b7eac7add281ef28ca5559f":{"price":{"6508":"180.00","6507":"180.00","6506":"180.00","6505":"180.00","6509":"180.00","6510":"180.00","6514":"180.00","6513":"180.00","6512":"180.00","6511":"180.00","6504":"180.00","6503":"180.00","6497":"180.00","6496":"180.00","6495":"180.00","6494":"180.00","6498":"180.00","6499":"180.00","6502":"180.00","6501":"180.00","6500":"180.00","6515":"180.00","6516":"180.00","6531":"180.00","6530":"180.00","6529":"180.00","6528":"180.00","6532":"180.00","6533":"180.00","6537":"180.00","6536":"180.00","6535":"180.00","6534":"180.00","6527":"180.00","6526":"180.00","6520":"180.00","6519":"180.00","6518":"180.00","6517":"180.00","6521":"180.00","6522":"180.00","6525":"180.00","6524":"180.00","6523":"180.00","6493":"180.00","6492":"180.00","6463":"180.00","6462":"180.00","6461":"180.00","6460":"180.00","6464":"180.00","6465":"180.00","6469":"180.00","6468":"180.00","6467":"180.00",[...]
MySQL said: Documentation
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 ''{"f9e544f77b7eac7add281ef28ca5559f":{"price":{"6508":"180.00","6507":"180.00","' at line 1
I've exported and imported many WordPress sites before and never had this happen. The WordPress site is using WooCommerce.
What can be done to fix this?

This looks like an escaping problem, so you should escape the double quotes in your file.
Try to add this as the last value:
REPLACE(#Data.pluginText, '"', '\"')
So your file should look like:
INSERT INTO wp_options VALUES (186159, '_transient_wc_var_prices_575', '{"f9e544f77b7eac7add281ef28ca5559f":{"price":{"6508":"180.00","6507":"180.00","6506":"180.00","6505":"180.00","6509":"180.00","6510":"180.00","6514":"180.00","6513":"180.00","6512":"180.00","6511":"180.00","6504":"180.00","6503":"180.00","6497":"180.00","6496":"180.00","6495":"180.00","6494":"180.00","6498":"180.00","6499":"180.00","6502":"180.00","6501":"180.00","6500":"180.00","6515":"180.00","6516":"180.00","6531":"180.00","6530":"180.00","6529":"180.00","6528":"180.00","6532":"180.00","6533":"180.00","6537":"180.00","6536":"180.00","6535":"180.00","6534":"180.00","6527":"180.00","6526":"180.00","6520":"180.00","6519":"180.00","6518":"180.00","6517":"180.00","6521":"180.00","6522":"180.00","6525":"180.00","6524":"180.00","6523":"180.00","6493":"180.00","6492":"180.00","6463":"180.00","6462":"180.00","6461":"180.00","6460":"180.00","6464":"180.00","6465":"180.00","6469":"180.00","6468":"180.00","6467":"180.00", REPLACE(#Data.pluginText, '"', '\"') );

Related

Importing wordpress content into phpmyadmin

I am trying to import one site into Wordpress multisite using phpmyadmin. I have tested on another single site and code imports. I change the wp_ to wp_g22_ and try importing into multi site and get this error:
SQL query:
INSERT INTO wp_g22_options (option_id, option_name, option_value, autoload) VALUES (252433, '_transient_jm_cats_d27300020302d47e080e7e962d68d506', 'a:47:{i:0;O:7:"WP_Term":12:{s:7:"term_id";i:398;s:4:"name";s:13:"Accommodation";s:4:"slug";s:13:"accommodation";s:10:"term_group";i:0;s:16:"term_taxonomy_id";i:418;s:8:"taxonomy";s:20:"job_listing_category";s:11:"description";s:248:"Whatever your budget, find accommodation in Herefordshire, Worcestershire, Gloucestershire, Monmouthshire, Shropshire & Powys. Our Guide2 covers hotels, B&Bs, self-catering, camping, glamping, farmhouses and more.\r\n\r\n ";s:6:"parent";i:0;s:5:"count";i:124;s:6:"filter";s:3:"raw";s:9:"term_type";s:1:"0";s:14:"term_font_icon";s:1:"0";}i:1;O:7:"WP_Term":12:{s:7:"term_id";i:437;s:4:"name";s:10:"Activities";s:4:"slug";s:10:"activities";s:10:"term_group";i:0;s:16:"term_taxonomy_id";i:457;s:8:"taxonomy";s:20:"job_listing_category";s:11:"description";s:418:"The ultimate guide[...]
MySQL said:
Documentation
#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 ''a:47:{i:0;O:7:"WP_Term":12:{s:7:"term_id";i:398;s:4:"name";s:13:"Accommodation"' at line 2

import .db file to mySQL

I am trying to export my blog on Yola and migrate to wordpress but I am having some trouble. Yola does not let you export your posts, but after lots of digging online (How to convert .db file to .sql file) I was able to figure out how to download my posts as a .db file.
After more digging online I was able to convert it to a .sql file using a program called Valentina Studio.
When I try to import the file into mySQL I get this error:
SQL query:
INSERT INTO "BlogPostBlogTag"( "tagId", "postId" )
VALUES (
'8a49866b2d872c90012d9bb4a6bf4767', '8a4986c9436bcaa201436c2df939023f'
);
MySQL said: Documentation
.#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 '"BlogPostBlogTag"("tagId","postId") VALUES ( '8a49866b2d872c90012d9bb4a6bf4767',' at line 1
Would anyone have any suggestions on successfully importing the file into mySQL?
Try this with one quote:
INSERT INTO 'BlogPostBlogTag'('tagId','postId')
VALUES (
'8a49866b2d872c90012d9bb4a6bf4767',
'8a4986c9436bcaa201436c2df939023f'
);

#1064 error in importing database php mysql localhost

I have backup of my live site's database. I want to run it on localhost. I tried to import the back up database that I craeted in phpmyadmin/localhost. But I am getting error something like this:
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 '
"http://www.w' at line 1
Can Any one help me....
This doesn't look like an SQL file, but as Krister Andersson suggested, you should post a few lines so we can see exactly what you are dealing with. How did you create the backup? What file type does it claim to be (is there an extension on the file)?

importing .sql3 and csv file into mysql workbench

This is may be foolish question. But i cant find the answer of this problem anywhere.
i have a .sql3 and a .csv file i want do import functionality in my mysql workbench using any of these file.
right now i dont have any tables and shemas in my mysql
when i am importing my demo.csv or demo.sql3 files in my workbench its showing an error like
ERROR 1064 (42000) at line 1: 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 'SQLite format 3' at line 1
I am on ubuntu
can anyone help me out from this problem
thanks in advance
For reading csv data into MySQL LOAD DATA is probably the best way to go. There's a plugin in MySQL WOrkbench for importing CSV data but it requires an existing result set.

How to bulk insert a csv file?

BULK INSERT krissmall
FROM 'C:\Users\Administrator\Downloads\misskrisdata_small.csv'
WITH (FIELDTERMINATOR = ',', ROWTERMINATOR = '\n')
ERROR 1064 (42000): 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 'BULK
INSERT krissmall FROM 'C:\Users\Administrator\Downloads\misskrisdata_small.' at
line 1
Can someone please tell me where went wrong? Or some other reasons behind this. I stared at this query for a long time, and looked it up a lot but I cannot find where it is wrong.
I'm curious where you looked up BULK INSERT since that doesn't seem to be supported by MySQL at all. Maybe you're reading MS SQL documentation and confusing the two.
What you want is LOAD DATA INFILE which can parse CSV.
You tagged phpmyadmin which leads me to believe that you are trying to execute this query from a remote server (possibly a web host). The remote server can't connect to your local drive. You must import through phpMyAdmin or upload the file you wish to import to a directory that phpMyAdmin can see.