Entry
How can I copy a table from one database to another?
Mar 2nd, 2000 21:36
Kenneth Cobler, Nathan Wallace, Ronald Beck, Sasha Pachev
My recommendation would be to perform a mysqldump of your current
database and then edit the file to load the data into the other
database. You can either leave the table creation information or remove
it if your table is already created. Seems the simplest idea to me.
mysqldump -uuser -ppass -h from_host db_from_name | mysql -uuser -ppass
-h to_host db_to_name
Just replace user,pass, from_host, to_host, db_from_name, db_to_name
with their appropriate values.
The simplest idea for me is to shut the database server down (mysqladmin
shutdown), copy the tables (i.e., MyTable.*) from
/var/lib/mysql/old_database to
/var/lib/mysql/new_database and then restart the database server.