1

I am working on exporting a table from my server DB which is about few thousand rows and the PHPMyadmin is unable to handle it.So I switched to the command line option
But I am running into this error after executing the mysqldump command.The error is

Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=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 'OPTION SQL_QUOTE_SHOW_CREATE=1' at line 1 (1064)
After doing some search on the same I found this as a bug in the mysql version 5.5 not supporting the SET OPTION command.

I am running a EC2 instance with centos on it.My mysql version is 5.5.31(from my phpinfo).
I would like to know if there is a fix for this as it wont be possible to upgrade the entire database for this error.
Or if there is any other alternative to do a export or dump,please suggest.

4
  • How about using grep/sed/awk to remove those lines from the dump? Commented Feb 12, 2014 at 12:42
  • I believe you're talking about replacing the SET OPTION to SET right?I rad about it but I am not that good at unix and so refraing from doing so! :P Can you help me with the actual command for it? Commented Feb 12, 2014 at 12:47
  • did you need the table structure of just the data? if you just need the data could you use select into and create a file? (dev.mysql.com/doc/refman/5.6/en/select-into.html) Commented Feb 12, 2014 at 12:51
  • only Data can do,I will try it! Can I import it back by using mysql import feature?? Commented Feb 12, 2014 at 12:58

3 Answers 3

1

An alternative to mysqldump is the SELECT ... INTO form of SELECT, which allows results to be written to a file (http://dev.mysql.com/doc/refman/5.5/en/select-into.html).

Some example syntax from the above help page is:

SELECT a,b,a+b INTO OUTFILE '/tmp/result.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;

Data can then be loaded back in using LOAD DATA INFILE (http://dev.mysql.com/doc/refman/5.5/en/load-data.html).

Again the page gives an example:

LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test
FIELDS TERMINATED BY ','  LINES STARTING BY 'xxx';

And with a complete worked example pair:

When you use SELECT ... INTO OUTFILE in tandem with LOAD DATA INFILE to write data from a database into a file and then read the file back into the database later, the field- and line-handling options for both statements must match. Otherwise, LOAD DATA INFILE will not interpret the contents of the file properly. Suppose that you use SELECT ... INTO OUTFILE to write a file with fields delimited by commas:

SELECT * INTO OUTFILE 'data.txt'   FIELDS TERMINATED BY ','   
FROM table2;

To read the comma-delimited file back in, the correct statement would be:

 LOAD DATA INFILE 'data.txt' INTO TABLE table2   FIELDS TERMINATED BY ',';
Sign up to request clarification or add additional context in comments.

2 Comments

a,b,a+b refer to the columns right? so I can do a * over there!??
yup, anything you can do in a normal query.
1

Not tested, but something like this:

cat yourdumpfile.sql | grep -v "SET OPTION SQL_QUOTE_SHOW_CREATE" | mysql -u user -p -h host databasename

This inserts the dump into your database, but removes the lines containing "SET OPTION SQL_QUOTE_SHOW_CREATE". The -v means reverting.

Couldn't find the english manual entry for SQL_QUOTE_SHOW_CREATE to link it here, but you don't need this option at all, when your table and database names don't include special characters or something (meaning they don't need to put in quotes).

UPDATE:

mysqldump -u user -p -h host database | grep -v "SET OPTION SQL_QUOTE_SHOW_CREATE" > yourdumpfile.sql

Then when you insert the dump into database you have to do nothing special.

mysql -u user -p -h host database < yourdumpfile.sql

3 Comments

So I should test it something like this cat yourdumpfile.sql | grep -v "SET OPTION SQL_QUOTE_SHOW_CREATE" | mysqldump -u root1 -p -h prod-DB-enpoint my_db tbl_revision Am I right??
No, you already have your dumpfile, right? No dumping, just mysql so you insert the dump into your database. Updated answer as well.
I want to export it first and I get the error while exporting as I mentioned in question!
0

I used quick and dirty hack for this.

  1. Download mysql 5.6. (from https://downloads.mariadb.com/archive/signature/p/mysql/f/mysql-5.6.13-linux-glibc2.5-x86_64.tar.gz/v/5.6.13)
  2. Untar and use newly downloaded mysqldump.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.