Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (18.4k points)

I have the .sql file with an export from phpMyAdmin. I want to import it into a different server using a command line.

I have the Windows Server 2008 R2 installation. I placed a .sql file on my C drive, and I tried the below command

database_name < file.sql

It is gitting me syntax errors.

  • How can I import the file without the above problem?
  • Do I need to create the database first?

 

1 Answer

0 votes
by (36.8k points)

Try:

mysql -u username -p database_name < file.sql

Check the MySQL Options.

Note-1: It is better to use a full path of a SQL file file.sql.

Note-2: Use the -R and the --triggers to keep routines and triggers of this original database. They are not copied with default.

Note-3 You may have to create an (empty) database from a MySQL if it doesn't exist already and an exported SQL doesn't contain the CREATE DATABASE (exported with --no-create-db or -n option) before you can import it.

Come and join Linux training to gain great knowledge. 

Related questions

0 votes
1 answer
0 votes
1 answer

Browse Categories

...