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_size etc.). But it does not work for me. So I want to import it by command line.
I used these commands for import the file:
mysql -u root -p sysdat < D:\Nisarg\ISPC\Database\sysdat.sql
mysql -u root -p -D sysdat < D:\Nisarg\ISPC\Database\sysdat.sql
mysql -u root sysdat < D:\Nisarg\ISPC\Database\sysdat.sql -p
These all are not working.
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)
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 :
and
The last parameter {mydbname} of the mysql command can be misleading : if
CREATE DATABASE
anUSE
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
andUSE
is :Use mysqldump without --databases to leave out
CREATE DATABASE
andUSE
:----------------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
---------------It's work with me -------------------
Try like this:
I think you need to use the full path at the command line, something like this, perhaps:
Refer this link also:
http://www.ryantetek.com/2011/09/importing-large-sql-files-through-command-line-when-using-phpmyadminxampp/
To import database from dump file use:
In wamp
To import database from dump file (in this case called filename.sql)
you are on Windows you will need to open CMD and go to directory where mysql.exe is installed. you are using WAMP server then this is usually located in: C:\wamp\bin\mysql\mysql5.5.8\bin (*note the version of mysql might be different)
So you will: cd C:\wamp\bin\mysql\mysql5.5.8\bin
and then execute one of the above commands. Final command like this