Xi Vix
Xi Vix

Reputation: 1361

How can I dump mysql table without using mysqldump?

I need to dump a table for daily transfer.
mysqldump requires LOCK TABLES privilege. Unfortunately, LOCK TABLES does not apply at the table level, only at the database level, and I don't want to give the MySQL user that much access. Is there a way to do something like ...

/usr/bin/mysql -uusername -ppassword -D daterbase -e "select * from table" > outfile.sql

... but have it output in SQL format instead of query result format?

Upvotes: 2

Views: 2849

Answers (1)

Bill Karwin
Bill Karwin

Reputation: 562348

If the table is an InnoDB table, you can use mysqldump --single-transaction dbname tablename.

By using a transaction, it doesn't need to lock anything.

Or you can use SELECT ... INTO OUTFILE but that dumps in a tab-delimited text format, not in SQL format. See on mysql for details.

Upvotes: 1

Related Questions