Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to export certain tables from one database and import them to another. The tables in question are used for my MediaWiki installation and are prefixed with "wiki_".

I do not have access to phpMyAdmin, but I am able to connect to the server via SSH. I'm guessing I need to use the mysqldump command, but how do I specify that I only want to dump tables prefixed with "wiki_"?

share|improve this question
There's a manual page for this. – Nemo Apr 5 '15 at 22:10
up vote 4 down vote accepted

You have to generate the list of tables you want to dump then act upon it.

mysql -u USER -p -D test -Bse "show tables like 'wiki_%'" >tables.out
mysqldump -u USER -p test <tables.out >wiki_tables.dump

or as a one liner

mysqldump -u USER -p test $(mysql -u USER -p -D test -Bse "show tables like 'wiki_%'")

but you still get to enter the password twice.

share|improve this answer

Since mysqldump can't work with wildcards, you will have to specify the tables you want:

mysqldump -u username -p database wiki_table1 wiki_table2 .. > database.sql

Or you could specify the tables you don't want to export:

mysqldump -u username -p database --ignore-table=atable --ignore-table=anothertabl > database.sql
share|improve this answer

Your Answer


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.