Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple DB import/export

Status
Not open for further replies.
May 22, 2002
63
0
0
GB
Hi,

Can anyone explain how to export multiple (i.e. ALL) DBs from one server as a single file then import then to a new server in one go?

Anderz
 
One way is to use mysqldump to export the databases and pipe that to a file:

mysqldump --databases --user=username -p db1 db2 db3 > file.txt

(The options "--user=username -p" instructs mysqldump to login to the server with a particular username and to ask for that user's password.)


On the foreign server, you can pipe that file into the mysql command-line query app:

mysql --user=username -p < file.txt

This will get your databases, tables, and table content over. You'll have to set up any necessary users yourself.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
I can only think of a binary export

If you copy all databases folders in the datadir path specified in the my.cnf (or my.ini if you use windoz) it will export all databases, including mysql DB and all related user/rights tables.

I have never done it but I think it works. You may need to restart the server without reading the grant tables.

If you don't copy the mysql DB instead I think it will work with no problems


Bye

Qatqat

Life is what happens when you are making other plans.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top