Phpmyadmin have a function is "Copy database to".. Is there any mysql query to write this function? something like copy db A to a new db B.
Asked
Active
Viewed 768 times
1
-
1You have to write script for that. Otherwise you can follow this: `mysqldump -u[user_name] -p[password] A > A.sql` Before doing the following Create database B; `mysql -u[user_name] -p[password] B < A.sql` – 1000111 Apr 20 '16 at 07:20
-
those is write in cmd right? there is no way to write a mysql query to do that? – Jasper Jye Apr 20 '16 at 07:25
-
yes in mysql command line interface. – 1000111 Apr 20 '16 at 07:25
-
1thanks your command is working... find out that can use exe("commands") in php to run the command.. – Jasper Jye Apr 20 '16 at 07:49
2 Answers
0
First create the duplicate database:
CREATE DATABASE duplicateddb;
Make sure the user and permissions are all in place and:
mysqldump -u[username] -p[password] | mysql -u[username] -p[password] duplicateddb;
0
Try to use mysqladmin and mysqldump in CLI, it provides such a functionality:
Some additional documentation, which could be useful for you:

Bandydan
- 623
- 1
- 8
- 24