4
Is there any way to duplicate a database on MYSQL by the execution of any query?
I can copy a table with this code:
CREATE TABLE table_2 AS SELECT * FROM table_1
But how to copy replicate a particular database (on the same host)?
4
Is there any way to duplicate a database on MYSQL by the execution of any query?
I can copy a table with this code:
CREATE TABLE table_2 AS SELECT * FROM table_1
But how to copy replicate a particular database (on the same host)?
5
It is possible (and easier) using mysqldump per command line:
mysqldump -h [servidor] -u root -e "create database banco_novo"
mysqldump -h [servidor] -u root banco_antigo|mysql -h [servidor] -u root banco_novo
However there are alternatives with php and bash:
Note that in PHP you can run command lines too, using exec() for example.
5
I usually do this outside of phpMyAdmin, using mysqldump in the shell. First you dump the current base:
mysqldump -R --user=usuario --password=senha nomedabase > arquivo.sql
The -R is to include procedures and functions in the dump. Then you create an empty base (can be by Myadmin or any client), and import the dump back:
mysql --user=usuario --password=senha basedestino < arquivo.sql
That operator < works the same way as cat of terminal?
The cat plays content for standard output. O < reads the file to default input.
Great example +1
Browser other questions tagged mysql phpmyadmin
You are not signed in. Login or sign up in order to post.
I like this technique, I’m going to adopt!
– bfavaretto