I'm trying to import a more or less large database ( 1Gb
) using PHPMyAdmin
.
The process is too slow and always cuts.
Is there a way to import a database MySQL
from the command line?
I'm trying to import a more or less large database ( 1Gb
) using PHPMyAdmin
.
The process is too slow and always cuts.
Is there a way to import a database MySQL
from the command line?
Using mysqldump
I was able to import a file sql
directly in the database.
cmd
: $ mysql -u <usuario> -p <nombreBaseDeDatos> < <archivo.sql>
Indicating the password ( insecure ):
$ mysql -u <usuario> -p<contraseña> <nombreBaseDeDatos> < <archivo.sql>
Powershell
$ Get-Content <archivo.sql> | mysql -u <usuario> -p <nombreBaseDeDatos>
Indicating the password ( insecure ):
$ Get-Content <archivo.sql> | mysql -u <usuario> -p<contraseña> <nombreBaseDeDatos>
Reference:
The answer I will give is not proven with files .sql
of that size 1GB
however I share it with you
.sql
file within Unit C, for example with a descriptive name C:.
├───backup.sql
mysql
you execute the following mysql -u root -p
password: *******
mysql> SOURCE C:/backup.sql;
The console depending on the number of tables should be returning something similar to the following
Query OK, 0 rows affected (0.11 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.10 sec)
Query OK, 0 rows affected (0.04 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 13 rows affected (11.51 sec)
Query OK, 1 row affected (0.22 sec)
.................................. more
CLARIFICATIONS
.sql
already contains in its structure the statements of: CREATE DATABASE
and
USE tuBaseDatos
then it is not necessary to create it but simply execute said command
.sql
then: First you must run
CREATE DATABASE TubaseDatos;
And later
USE TubaseDatos;
so that in the end we execute
SOURCE C:/backup.sql