Notes:
- There is no space between the option
-p
and the password. If your database has no password, remove the-u username -ppassword
part. - If some table has a trigger, it cannot be moved to another database using above method (will result
Trigger in wrong schema
error). If that is the case, use a traditional way to clone a database and then drop the old one:mysqldump old_db | mysql new_db
- If you have stored procedures, you can copy them afterwards:
mysqldump -R old_db | mysql new_db