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.
If you are running WampServer on your local machine, import means restoring the dump file that you have (in sql format)
Here are the steps
Change the directory to Mysql bin directory. It will be like
c:\wamp\bin\mysql\mysql5.7.14\bin
It would be better to keep the dump file in the above directory( we can delete, after restoration)
Hope you have created the database (either through phpMyadmin or using command line)
Then type the command
mysql.exe -u root -p databasename < filename.sql
Please note the difference, it is 'mysql.exe' not 'mysql'
Try this it will work. Do not enter password it will ask one you execute the following cmd
To import SQL file what works for me
For Wamp-Server
Open cmd and once you get inside bin you have to write " mysql -uroot -p database_name < filename.sql"
remember to put sql file under bin.
in nutshell you have to do this:-
After this, it will ask for the password, mine password was nothing(BLANK).
hope it helps someone.
If you are using Windows PowerShell you may get the error:
In that case just type the command:
To switch to the cmd shell and then retype the command and it will work.
To get back to PowerShell type:
TRY THIS
if username=root ,filepath='C:/test.sql', databasename='test' ,password ='' then command will be
I use
mysql -u root -ppassword databasename < filename.sql
in batch process. For an individual file, I like to usesource
more because it shows the progress and any errors likemysql -u root -ppassword
In MySQL, change the database you want to import in:
mysql>use databasename;
Import the SQL file using source command:
mysql>source path\to\the\file\filename.sql;