I have a .sql
file with an export from phpMyAdmin
. I want to import it into a different server using the command line.
I have a Windows Server 2008 R2 installation. I placed the .sql
file on the C drive, and I tried this command
database_name < file.sql
It is not working I get syntax errors.
- How can I import this file without a problem?
- Do I need to create a database first?
I think it's worth mentioning that you can also load a gzipped (compressed) file with
zcat
like shown below:The following command works for me from the command line (cmd) on Windows 7 on WAMP.
A solution that worked for me is below:
For information I just had default root + withoutpassword, it didn't works with all above answers.
I created a new user with all privileges and a password. It works.
-ppassword WITHOUT SPACE.
Use mysql help for details
mysql --help
I think these will be useful options in our context
what is fun, if we are importing a large database and not having a progress bar. Use Pipe Viewer and see the data transfer through the pipe
For Mac,
brew install pv
.For Debian/Ubuntu,apt-get install pv
. Others, refer http://www.ivarch.com/programs/pv.shtml