I am trying to run a sql file located at /desktop/folder/query.sql in command line. I have the database changed to the one that I need but am unsure how to execute the file. Thanks in advance for any help
-
1What is the problem with using MySQL-Doc: Executing SQL Statements from a Text File?t.niese– t.niese2014-12-01 20:39:49 +00:00Commented Dec 1, 2014 at 20:39
-
I seem to be getting an error when trying to specify a directory /desktop/folder/query.sql. The server is remote with the file being local on my machineamazingacademy– amazingacademy2014-12-01 20:43:19 +00:00Commented Dec 1, 2014 at 20:43
-
Just solved it. mysql> source desktop/folder/query.sqlamazingacademy– amazingacademy2014-12-01 20:45:50 +00:00Commented Dec 1, 2014 at 20:45
-
possible duplicate of How to import an SQL file using the command line in MySQL?t.niese– t.niese2014-12-01 20:49:04 +00:00Commented Dec 1, 2014 at 20:49
Add a comment
|
2 Answers
answering my own question,
mysql> source desktop/folder/query.sql;
Just had to use the 'source' prefix.
1 Comment
amazingacademy
Which is where i found it. Thanks for the link, and the downvote
Goto the File Path And then on Address bar of system hit ENTER then you will get redirect to cmd to that path: Then Runt Above command With Your Details like your Server Name/Instance Name then Filename with extention of .sql and in last add databse name.
sqlcmd -S myServer\instanceName -i C:\myScript.sql -d Database
Eg: sqlcmd -S DESKTOP-E73MBC3 -i sampleDBData.sql -d First_DB