I want to import an SQL file (size > 500MB) into a database. I have wamp on my PC. Phpmyadmin does not work well with this size. I changed all parameters in php.ini (max_upload_
Try this it will work. Do not enter password it will ask one you execute the following cmd
C:\xampp\mysql\bin\mysql -u xxxxx -p -h localhost your_database_name < c:\yourfile.sql
mysql : < (for import) > (for export)
in windows, you want to take backup or import the sql file, then goto cmd prompt type the address were the mysql is installed eg:C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin> after this
C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin> mysql -u UserName -p Password DatabaseName < FileName.sql (import)
C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin> mysql -u UserName -p Password DatabaseName > FileName.sql (export)
----------------WARM server.
step 1: go to cmd go to directory C:\wamp\bin\mysql\mysql5.6.17 hold Shift + right click (choose "open command window here")
step 2: C:\wamp\bin\mysql\mysql5.6.17\bin>mysql -u root -p SellProduct < D:\file.sql
in this case
+ Root is username database
+ SellProduct is name database.
+ D:\file.sql is file you want to import
---------------It's work with me -------------------
If you are using Windows PowerShell you may get the error:
The '<' operator is reserved for future use.
In that case just type the command:
cmd
To switch to the cmd shell and then retype the command and it will work.
c:\xampp\mysql\bin\mysql -u root -p my_database < my_database_dump.sql
To get back to PowerShell type:
exit
If those commands don't seems to work -- I assure you they do --, check the top of your sql dump file for the use of :
CREATE DATABASE {mydbname}
and
USE {mydbname}
The last parameter {mydbname} of the mysql command can be misleading : if CREATE DATABASE
an USE
are in your dump file, the import will in fact be done in this database, not in the one in the mysql command.
The mysqldump command that will prompt CREATE DATABASE
and USE
is :
mysqldump.exe -h localhost -u root --databases xxx > xxx.sql
Use mysqldump without --databases to leave out CREATE DATABASE
and USE
:
mysqldump.exe -h localhost -u root xxx > xxx.sql
If you have wamp installed then go to command prompt , go to the path where mysql.exe exists , like for me it was : C:\wamp\bin\mysql\mysql5.0.51b\bin , then paste the sql file in the same location and then run this command in cmd :
C:\wamp\bin\mysql\mysql5.0.51b\bin>mysql -u root -p YourDatabaseName < YourFileName.sql