1

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.

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
Jasper Jye
  • 81
  • 6
  • 1
    You 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
  • 1
    thanks 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 Answers2

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;

ref: Duplicate Entire MySQL Database

Community
  • 1
  • 1
Seda
  • 243
  • 1
  • 9
0

Try to use mysqladmin and mysqldump in CLI, it provides such a functionality:

MySQL Documentation

Some additional documentation, which could be useful for you:

link1

link2

Bandydan
  • 623
  • 1
  • 8
  • 24