How do I import an SQL file using the command line in MySQL?

Jaylen

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?
bansi

Try:

mysql -u username -p database_name < file.sql

Check MySQL Options.

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

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

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How do I install command line MySQL client on mac?

From Java

How do I import a .sql file in mysql database using PHP?

From Dev

How do I open a file with Chrome from the command line?

From Dev

How do I deploy a file to Artifactory using the command line?

From Dev

in MySQL Command Line, how do I paste from the clipboard using only the keyboard?

From Dev

How do I stop a batch file retaining control of the command line

From Dev

Import a mysql database using mysql command line

From Dev

How do i import a mysql dump to SQL Server database

From Dev

How do I easily rename multiple files using command line?

From Dev

How can I import a database using command line?

From Dev

How do I move window buttons from left to right using command line or by editing a specific file?

From Dev

How do I insert a line at the top of a text file using the command line?

From Dev

How do I install a .deb file via the command line?

From Dev

How do I easily rename multiple files using command line?

From Dev

How can I import a database using command line?

From Dev

How do I install a .deb file via the command line?

From Dev

How do I move window buttons from left to right using command line or by editing a specific file?

From Dev

How do I insert a line at the top of a text file using the command line?

From Dev

How do I move all files from one folder to a subfolder except .html file using the command line?

From Dev

How do I search a PDF file from command line?

From Dev

How do I replace the '&#x5c' with '/' in file using the command line?

From Dev

mysql-workbench, how do I write a bash file command as to launch and open a SQL script to a query tab?

From Dev

How do I get a specific line of a file using 'cat' command?

From Dev

How do I send a file with FileZilla from the command line?

From Dev

How do I run .c file from the command line

From Dev

How do i import a mysql dump to SQL Server database

From Dev

How do I change file headers from the command line?

From Dev

How do I find the biggest file in a folder and subfolders on the command line?

From Dev

How do I run a sql query on Ambari / Zeplin using a command line tool?

Related Related

  1. 1

    How do I install command line MySQL client on mac?

  2. 2

    How do I import a .sql file in mysql database using PHP?

  3. 3

    How do I open a file with Chrome from the command line?

  4. 4

    How do I deploy a file to Artifactory using the command line?

  5. 5

    in MySQL Command Line, how do I paste from the clipboard using only the keyboard?

  6. 6

    How do I stop a batch file retaining control of the command line

  7. 7

    Import a mysql database using mysql command line

  8. 8

    How do i import a mysql dump to SQL Server database

  9. 9

    How do I easily rename multiple files using command line?

  10. 10

    How can I import a database using command line?

  11. 11

    How do I move window buttons from left to right using command line or by editing a specific file?

  12. 12

    How do I insert a line at the top of a text file using the command line?

  13. 13

    How do I install a .deb file via the command line?

  14. 14

    How do I easily rename multiple files using command line?

  15. 15

    How can I import a database using command line?

  16. 16

    How do I install a .deb file via the command line?

  17. 17

    How do I move window buttons from left to right using command line or by editing a specific file?

  18. 18

    How do I insert a line at the top of a text file using the command line?

  19. 19

    How do I move all files from one folder to a subfolder except .html file using the command line?

  20. 20

    How do I search a PDF file from command line?

  21. 21

    How do I replace the '&#x5c' with '/' in file using the command line?

  22. 22

    mysql-workbench, how do I write a bash file command as to launch and open a SQL script to a query tab?

  23. 23

    How do I get a specific line of a file using 'cat' command?

  24. 24

    How do I send a file with FileZilla from the command line?

  25. 25

    How do I run .c file from the command line

  26. 26

    How do i import a mysql dump to SQL Server database

  27. 27

    How do I change file headers from the command line?

  28. 28

    How do I find the biggest file in a folder and subfolders on the command line?

  29. 29

    How do I run a sql query on Ambari / Zeplin using a command line tool?

HotTag

Archive