When you are going to do delicate operations on the database, either because of the nature of these operations, or because they require more time, it is better that you do it from the console or command line.
The time difference is considerable and you will have less risk of the operation failing or being blocked halfway.
Duplicating a database using the console is relatively easy.
You create the new database
CREATE DATABASE nuevabd;
You use mysqldump
to export all the contents of the old database to a file
Now you import the file created in step 2 to the new database
Let's see what the commands would look like. Suppose that:
the user is root
(can be any other with privileges to create databases)
the database that exists is called viejabd
the new database is called nuevabd
Step 1: Create nuevabd
:
We enter with our user:
>mysql -u root -p
Enter password: ********** -- aquí debes poner la password del usuario
We create the new database:
> CREATE DATABASE nuevabd;
You can check if it has been created:
> SHOW DATABASES
Step 2: Export the old database to a file .sql
We assume that the file will be saved in the directory c:\bd
>mysqldump -u root -p viejabd > c:\bd\viejabd.sql
Enter password: **********
What this command does is request entry to the bd by user root
and export the contents of viejabd
in a file called viejabd.sql
that will be in the indicated route. The >
symbol means export .
Step 3: We import the file created in step 2 to the new database
>mysql -u root -p nuevabd < c:\bd\viejabd.sql
Enter password: **********
Here the operator <
means import .
Then you can verify that everything went as expected
> SHOW TABLES FROM nuevabd;
It will show you a list of tables in the new database.