+2 votes
1 view
in SQL by (16k points)
edited by

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?

1 Answer

+5 votes
by (40.4k points)
edited by

Try this command line in MYSQL:

MySQL -u username -p database_name < file1.sql

Are you interested in learning SQL from scratch! Have a look at this interesting video on SQL provided by Intellipaat:

Note:

  •        It’s most recommended to use the full path of the SQL file file1.sql
  • I      If an empty database doesn’t exist and exported SQL don’t contain CREATE DATABASE(-n option or exported with - -no—create- -db ) then you may have to create one empty database before you import it.
  •        <!--[endif]-->You can use - -triggers and -R to keep the triggers of the original database. They will not be copied by default.

Related questions

0 votes
1 answer
asked Jul 11, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...