views:

9

answers:

2

Is it possible to extract a script from an MySQL database to create a copy of the tables on another MySQL database which is located on a remote server?

+2  A: 

You can dump either the structure of the tables, or their content, using the mysqldump command-line tool.

For example, to get a dump of the structure (create table instructions) of all tables of a database, you can use something like this :

mysqldump --no-data --user=USER_NAME --password=PASSWORD --host=HOST DATABASE_NAME


And, to get this to a file, instead of getting it to the standard output, you can redirect that output :

mysqldump --no-data --user=USER_NAME --password=PASSWORD --host=HOST DATABASE_NAME > dump-file.sql


If you also want the data of the tables, and not just their structure, do not use the --no-data option.


Then, on your other server, you can import the dump, using :

mysql --user=NEW_USER_NAME --password=NEW_PASSWORD --host=NEW_HOST NEW_DATABASE_NAME < dump-file.sql
Pascal MARTIN
+1  A: 

Do you mean to extract a 'dump'?
yes of course. mysqldump utility is the general choice

Col. Shrapnel