Reputation: 9415
I am looking for a query to copy data from one database/table to another database/table with different user credentials?
Upvotes: 0
Views: 3811
Reputation: 174622
Not a query, unless your user has rights on both schemas.
Try this mysqldump -u user dbname.tablename | mysql -u user2 dbname
Upvotes: 1
Reputation: 9415
Looks like there is no straight way to copy any database to another database with different users.
Only way I could successfully complete this task is to write a script to take the dump and run it over another database.
Upvotes: 0
Reputation: 550
To copy data from one table to another :
INSERT INTO TABLE2 (COL1, COL2, COL3) SELECT COL1, COL4, COL7 FROM TABLE1
To copy data from one database to another :
USE `old_database`;
INSERT INTO `new_database`.`new_table`(`column1`,`column2`,`column3`)
SELECT `old_table`.`column2`, `old_table`.`column3`, `old_table`.`column5`
FROM `old_table`
Upvotes: 2