I have database1 (~500MB), which can be access in a read-only mode by user1.
I have empty database database2, with full privilege by user2.
Now, I want to clone database1 into database2.
I have tried mysqldump, but it says access denied.
Any better way? Thanks.
By default, mysqldump tries to lock all tables before dumping them – in order to create a consistent snapshot. I assume that
user1does not have the privilege to do that.You can use either
--single-transactionor--skip-lock-tableson the command line. The first option uses a single transaction for the whole operation. This works perfectly if all tables are transactional and the database is small. If the database is huge, this can have serious effects on other applications.If in doubt, try
--skip-lock-tablesfirst. However, the dump may be inconsistent, if other applications make changes during the dump.Complete example to clone database: