tags:

views:

17

answers:

2

how to export table records as insert in mysql using mysql query browser?

is there any other tool that can do it?

+2  A: 

You might use the mysqldump utility if you have access to it. An example might be

C:\mydir> mysqldump <database> -u<username> -p<password> -t -n -c <table>
martin clayton
in C:\Xampp\MYSQL\BIN, I run mysql -u root then did this: mysql> mysqldump -u test -p test –all-databases > dump.sql; this didnt work
user1111111
@sam - Sorry, answer is not clear enough - run mysqldump _instead of_ mysql.
martin clayton
yes, same directory
user1111111
+1 , urs should work as well,
user1111111
+1  A: 

The old school way is to use string concatenation:

SELECT CONCAT('INSERT INTO YOUR_TABLE (col1, col2) VALUES(', t.col1,',', t.col2, ')')
  FROM YOUR_TABLE t

Copy the output to a script. Mind that you'll have to handle data types appropriately (IE date/time).

But I have to wonder why you don't just use mysqldump, and get the INSERT statement out of the per table backup.

OMG Ponies
Syntax error didnt run
user1111111
@sam: I forgot a bracket, try now.
OMG Ponies
very nice trick
user1111111