Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to get mysqldump to output USE statements for a single (partial) table dump?

I've already got some scripts that I'd like to reuse which run mysqldump with some arguments and apply them to a remote server.

However, since I haven't bothered to parse all the arguments to mysqldump, and there is no USE in the dump, the remote server is saying no database selected.

I'm a programmer more than anything else, so I can easily use sed to modify the dump before applying it in the worst case, but those scripts won't allow me to do this as I don't have access to the dump between creation and application.

EDIT: the ability to output fully qualified table names may also solve my problem

share|improve this question

1 Answer 1

up vote 1 down vote accepted

mysqldump can be cajoled into performing as requested by combining the --databases (force USE statements on databases) and --tables (force following arguments to be evaluated as tables) flags:

mysqldump -B dbname --tables tablename

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.