• support@answerspoint.com

How to copy a table from one mysql database to another mysql database

1898

I need to copy a table from one database to another. This will be a cronjob. Which one is the best way to do it? PHP script or Shell Script. The problem with PHP, both databases has different usernames and passwords so I can't do it like this.

CREATE TABLE db1.table1 SELECT * FROM db2.table1

I prefer a shell script to do this instead of PHP script.

Thanks

1Answer


0

The West way to copy table from one databse to another is dump method.

mysqldump -u user1 -ppassword1 databasename > dump.sql
mysql -u user2 -ppassword2 databasename < dump.sql
  • answered 7 years ago
  • Community  wiki

Your Answer

    Facebook Share        
       
  • asked 7 years ago
  • viewed 1898 times
  • active 7 years ago

Best Rated Questions