mysql: SOURCE error 2?
When I tried to source for a particular .sql file, namely 'metropolises.sql'
that I created and saved previously from a database, the following error is displayed:
Failed to open file 'metropolises.sql', error: 2
Any idea what went wrong?
mysql
add a comment |
When I tried to source for a particular .sql file, namely 'metropolises.sql'
that I created and saved previously from a database, the following error is displayed:
Failed to open file 'metropolises.sql', error: 2
Any idea what went wrong?
mysql
1
What does it mean to "try to source for a particuar .sql file"?
– Lightness Races in Orbit
Feb 4 '13 at 9:51
1
Did you mean "search"?
– veljasije
Feb 4 '13 at 9:54
I created a table in a database. Now, in order to get the data created, I typed SOURCE metropolises.sql; into the terminal, however the error message as described above showed up. Pretty sure there's no error in the table created.
– Clueless Gorilla
Feb 4 '13 at 10:22
add a comment |
When I tried to source for a particular .sql file, namely 'metropolises.sql'
that I created and saved previously from a database, the following error is displayed:
Failed to open file 'metropolises.sql', error: 2
Any idea what went wrong?
mysql
When I tried to source for a particular .sql file, namely 'metropolises.sql'
that I created and saved previously from a database, the following error is displayed:
Failed to open file 'metropolises.sql', error: 2
Any idea what went wrong?
mysql
mysql
edited Feb 4 '13 at 9:48
Clueless Gorilla
asked Feb 4 '13 at 9:46
Clueless GorillaClueless Gorilla
5042613
5042613
1
What does it mean to "try to source for a particuar .sql file"?
– Lightness Races in Orbit
Feb 4 '13 at 9:51
1
Did you mean "search"?
– veljasije
Feb 4 '13 at 9:54
I created a table in a database. Now, in order to get the data created, I typed SOURCE metropolises.sql; into the terminal, however the error message as described above showed up. Pretty sure there's no error in the table created.
– Clueless Gorilla
Feb 4 '13 at 10:22
add a comment |
1
What does it mean to "try to source for a particuar .sql file"?
– Lightness Races in Orbit
Feb 4 '13 at 9:51
1
Did you mean "search"?
– veljasije
Feb 4 '13 at 9:54
I created a table in a database. Now, in order to get the data created, I typed SOURCE metropolises.sql; into the terminal, however the error message as described above showed up. Pretty sure there's no error in the table created.
– Clueless Gorilla
Feb 4 '13 at 10:22
1
1
What does it mean to "try to source for a particuar .sql file"?
– Lightness Races in Orbit
Feb 4 '13 at 9:51
What does it mean to "try to source for a particuar .sql file"?
– Lightness Races in Orbit
Feb 4 '13 at 9:51
1
1
Did you mean "search"?
– veljasije
Feb 4 '13 at 9:54
Did you mean "search"?
– veljasije
Feb 4 '13 at 9:54
I created a table in a database. Now, in order to get the data created, I typed SOURCE metropolises.sql; into the terminal, however the error message as described above showed up. Pretty sure there's no error in the table created.
– Clueless Gorilla
Feb 4 '13 at 10:22
I created a table in a database. Now, in order to get the data created, I typed SOURCE metropolises.sql; into the terminal, however the error message as described above showed up. Pretty sure there's no error in the table created.
– Clueless Gorilla
Feb 4 '13 at 10:22
add a comment |
19 Answers
19
active
oldest
votes
Assuming you mean that you are trying to use the source
command in order to execute SQL statements from a text file, the error number given appears to be passed through from the POSIX layer.
Therefore, using this resource, we can deduce that the error value of 2 means "no such file or directory".
In short, you got the path wrong.
Try providing an absolute path, as it's not clear what the current working directory will be in the context of your MySQL server. You may be assuming that it's the working directory of your shell, but it's not obvious that we should expect this to be true.
Thanks. I know this is stupid, but how to find the file I created under within a database?
– Clueless Gorilla
Feb 4 '13 at 10:29
Provide an absolute path. The full path. Including directory.
– Lightness Races in Orbit
Feb 4 '13 at 10:41
6
As an added note, do not put the full path in quotes.SOURCE "/var/test.sql";
will fail with error code 2, whileSOURCE /var/test.sql
will work (assuming test.sql exists at that location).
– Will Martin
Jun 2 '15 at 21:11
yup, just a simple misspelling of the sql file triggered mine
– Manuel Hernandez
Feb 24 '16 at 22:13
Why are they not just throwing "no such file or directory" instead of a cryptic error code number ..???
– Black
May 27 '18 at 14:59
|
show 1 more comment
Just use the absolute path of the file and then, instead of using backslashes, use forward slashes.
Example:
with backslashes : source C:folder1metropolises.sql
with forward slashes : source C:/folder1/metropolises.sql
1
Do you know if it is possible to store the path in a global or local variable (e.g @PATH_TO_THE_FILE) and use the source command as in "source @PATH_TO_THE_FILE" (this does not work)? Thanks.
– aloplop85
Jul 25 '13 at 13:38
1
Hi, you helped me with your answer! Thanks a lot! =)
– Daniel Garcia Sanchez
Jul 1 '15 at 13:22
add a comment |
Related issue I had getting error 2 running source command: filename must not be in quotes even if it contains spaces in name or path to file.
Ah, this was my problem, thanks!
– sage88
Aug 5 '14 at 19:58
One tends to think that with spaces in the path quotes are necessary. What a headache!
– PavoDive
Mar 31 '16 at 11:40
add a comment |
I first reach to the file
c:windows>cd c:akuraDb Scripts
c:akuraDb Scripts>mysql -u root -p root
mysql>. EXECUTER_NEW_USER.sql
here EXECUTER_NEW_USER.sql my file name
add a comment |
It's probably the file path to your file. If you don't know the exact location of the file you want to use, try to find your file in Finder, then drag the file into Terminal window
mysql> SOURCE dragfilePathHere
add a comment |
I've had the same error on Windows.
I solved it with (after on cmd: mysql -u root):
mysql> SOURCE C:/users/xxx/xxxx/metropolises.sql;
Be sure you type the right file path
add a comment |
If you are using vagrant ensure that the file is on the server and then use the path to the file. e.g if the file is stored in the public folder you will have
sql> source /var/www/public/xxx.sql
Where xxx is the name of the file
add a comment |
I got this error in mysql command line using this query:
source `db.sql`;
I changed the above to the following to make it work:
source db.sql;
add a comment |
On my windows 8.1, and mysql 5.7.9 MySQL Community Server (GPL),
I had to remove the ;
after the file path.
This failed: source E:/jokoni/db/Banking/createTables.sql;
This Worked: source E:/jokoni/db/Banking/createTables.sql
(without termination, and forward slashes instead of windows' backslashes in path)
Same as you, but I wonder why?
– Akshat Agarwal
Jan 16 '16 at 5:43
add a comment |
May be the file name or path you are used may be incorrect
In my system i created file abcd.sql at c:
and used command mysql> source c:abcd.sql
Then i got result
Actually, I'm doing it on ssh. How to view the directories of the files created on a particular database?
– Clueless Gorilla
Feb 4 '13 at 10:24
@PengHuiHow - do you know the actual path of that file?
– Fathah Rehman P
Feb 4 '13 at 10:42
add a comment |
If you're on Debian 8 (Jessie) Linux, try to cd
into the directory of the 'metropolises.sql'
. Run mysql
and execute SOURCE ./metropolises.sql;
Basically, try the relative path. I tried this and it works.
add a comment |
If you are running dockerized MySQL container such as ones from this official Docker Image registry: https://hub.docker.com/_/mysql/ You may encounter this issue as well.
add a comment |
For me it was because the file was located on a shared drive and it could not access, for some reason, to that path.
I cut the file and put it on my local drive in a path without spaces and it got resolved.
add a comment |
I got the same error when i used the command source and gave the sql file path by drag n dropping it.
Then I just had to remove those single quotes which appeared by default with drag and drop, a space before file extension and it worked.
soln:
source /home/xyz/file .sql ;(path and a space before file extension)
add a comment |
For Mac users, you can give the path as,
source /Users/YOUR_USER_NAME/Desktop/metropolises.sql;
*I have assumed that the file you need to source
is in your desktop
and the file name is metropolises.sql
If you type,
source metropolises.sql
then the file will be look in the default location,
/Users/YOUR_USER_NAME/metropolises.sql;
add a comment |
The solution for me was file permissions in Windows. Just give full control in the file to all users and it will work. After the import, get the permissions back to what it was before.
add a comment |
On my Mac, this is the only solution worked for me.
https://stackoverflow.com/a/45530305/5414448
1 - Download the .sql file and remember it's location.
2 - Open your mysql from command prompt or terminal.
3 - Create a database with the same name as that of the database present in the .sql file (create database your_database_name)
4 - Now exit out from the mysql command line client
5 - Now try and execute this command =>
mysql -u your_username -p your_database_name < your_sql_file_with_complete_location
example - mysql -u root -p trial < /home/abc/Desktop/trial.sql
here my .sql file is named trial and is present in the desktop, the database is also name trial
6 - You should now have your sql file imported to the corresponding mysql database.
add a comment |
Remove spaces in the folder names of the path, It worked for my mac path.
(Eg: change the folder name MySQL Server 5.1 to MySQLServer5.1)
add a comment |
I also got the same message when I try from the MySQL console. However, when I open the command prompt and do the same steps it works.
C:UsersSubhenduD>cd ../
C:Users>cd ../
C:>cd xamppmysqlbin
C:xamppmysqlbin>mysql -u -root
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 68
Server version: 5.6.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> use balticktravels;
mysql> source balticktravels.sql;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14684063%2fmysql-source-error-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
19 Answers
19
active
oldest
votes
19 Answers
19
active
oldest
votes
active
oldest
votes
active
oldest
votes
Assuming you mean that you are trying to use the source
command in order to execute SQL statements from a text file, the error number given appears to be passed through from the POSIX layer.
Therefore, using this resource, we can deduce that the error value of 2 means "no such file or directory".
In short, you got the path wrong.
Try providing an absolute path, as it's not clear what the current working directory will be in the context of your MySQL server. You may be assuming that it's the working directory of your shell, but it's not obvious that we should expect this to be true.
Thanks. I know this is stupid, but how to find the file I created under within a database?
– Clueless Gorilla
Feb 4 '13 at 10:29
Provide an absolute path. The full path. Including directory.
– Lightness Races in Orbit
Feb 4 '13 at 10:41
6
As an added note, do not put the full path in quotes.SOURCE "/var/test.sql";
will fail with error code 2, whileSOURCE /var/test.sql
will work (assuming test.sql exists at that location).
– Will Martin
Jun 2 '15 at 21:11
yup, just a simple misspelling of the sql file triggered mine
– Manuel Hernandez
Feb 24 '16 at 22:13
Why are they not just throwing "no such file or directory" instead of a cryptic error code number ..???
– Black
May 27 '18 at 14:59
|
show 1 more comment
Assuming you mean that you are trying to use the source
command in order to execute SQL statements from a text file, the error number given appears to be passed through from the POSIX layer.
Therefore, using this resource, we can deduce that the error value of 2 means "no such file or directory".
In short, you got the path wrong.
Try providing an absolute path, as it's not clear what the current working directory will be in the context of your MySQL server. You may be assuming that it's the working directory of your shell, but it's not obvious that we should expect this to be true.
Thanks. I know this is stupid, but how to find the file I created under within a database?
– Clueless Gorilla
Feb 4 '13 at 10:29
Provide an absolute path. The full path. Including directory.
– Lightness Races in Orbit
Feb 4 '13 at 10:41
6
As an added note, do not put the full path in quotes.SOURCE "/var/test.sql";
will fail with error code 2, whileSOURCE /var/test.sql
will work (assuming test.sql exists at that location).
– Will Martin
Jun 2 '15 at 21:11
yup, just a simple misspelling of the sql file triggered mine
– Manuel Hernandez
Feb 24 '16 at 22:13
Why are they not just throwing "no such file or directory" instead of a cryptic error code number ..???
– Black
May 27 '18 at 14:59
|
show 1 more comment
Assuming you mean that you are trying to use the source
command in order to execute SQL statements from a text file, the error number given appears to be passed through from the POSIX layer.
Therefore, using this resource, we can deduce that the error value of 2 means "no such file or directory".
In short, you got the path wrong.
Try providing an absolute path, as it's not clear what the current working directory will be in the context of your MySQL server. You may be assuming that it's the working directory of your shell, but it's not obvious that we should expect this to be true.
Assuming you mean that you are trying to use the source
command in order to execute SQL statements from a text file, the error number given appears to be passed through from the POSIX layer.
Therefore, using this resource, we can deduce that the error value of 2 means "no such file or directory".
In short, you got the path wrong.
Try providing an absolute path, as it's not clear what the current working directory will be in the context of your MySQL server. You may be assuming that it's the working directory of your shell, but it's not obvious that we should expect this to be true.
answered Feb 4 '13 at 9:59
Lightness Races in OrbitLightness Races in Orbit
291k52475808
291k52475808
Thanks. I know this is stupid, but how to find the file I created under within a database?
– Clueless Gorilla
Feb 4 '13 at 10:29
Provide an absolute path. The full path. Including directory.
– Lightness Races in Orbit
Feb 4 '13 at 10:41
6
As an added note, do not put the full path in quotes.SOURCE "/var/test.sql";
will fail with error code 2, whileSOURCE /var/test.sql
will work (assuming test.sql exists at that location).
– Will Martin
Jun 2 '15 at 21:11
yup, just a simple misspelling of the sql file triggered mine
– Manuel Hernandez
Feb 24 '16 at 22:13
Why are they not just throwing "no such file or directory" instead of a cryptic error code number ..???
– Black
May 27 '18 at 14:59
|
show 1 more comment
Thanks. I know this is stupid, but how to find the file I created under within a database?
– Clueless Gorilla
Feb 4 '13 at 10:29
Provide an absolute path. The full path. Including directory.
– Lightness Races in Orbit
Feb 4 '13 at 10:41
6
As an added note, do not put the full path in quotes.SOURCE "/var/test.sql";
will fail with error code 2, whileSOURCE /var/test.sql
will work (assuming test.sql exists at that location).
– Will Martin
Jun 2 '15 at 21:11
yup, just a simple misspelling of the sql file triggered mine
– Manuel Hernandez
Feb 24 '16 at 22:13
Why are they not just throwing "no such file or directory" instead of a cryptic error code number ..???
– Black
May 27 '18 at 14:59
Thanks. I know this is stupid, but how to find the file I created under within a database?
– Clueless Gorilla
Feb 4 '13 at 10:29
Thanks. I know this is stupid, but how to find the file I created under within a database?
– Clueless Gorilla
Feb 4 '13 at 10:29
Provide an absolute path. The full path. Including directory.
– Lightness Races in Orbit
Feb 4 '13 at 10:41
Provide an absolute path. The full path. Including directory.
– Lightness Races in Orbit
Feb 4 '13 at 10:41
6
6
As an added note, do not put the full path in quotes.
SOURCE "/var/test.sql";
will fail with error code 2, while SOURCE /var/test.sql
will work (assuming test.sql exists at that location).– Will Martin
Jun 2 '15 at 21:11
As an added note, do not put the full path in quotes.
SOURCE "/var/test.sql";
will fail with error code 2, while SOURCE /var/test.sql
will work (assuming test.sql exists at that location).– Will Martin
Jun 2 '15 at 21:11
yup, just a simple misspelling of the sql file triggered mine
– Manuel Hernandez
Feb 24 '16 at 22:13
yup, just a simple misspelling of the sql file triggered mine
– Manuel Hernandez
Feb 24 '16 at 22:13
Why are they not just throwing "no such file or directory" instead of a cryptic error code number ..???
– Black
May 27 '18 at 14:59
Why are they not just throwing "no such file or directory" instead of a cryptic error code number ..???
– Black
May 27 '18 at 14:59
|
show 1 more comment
Just use the absolute path of the file and then, instead of using backslashes, use forward slashes.
Example:
with backslashes : source C:folder1metropolises.sql
with forward slashes : source C:/folder1/metropolises.sql
1
Do you know if it is possible to store the path in a global or local variable (e.g @PATH_TO_THE_FILE) and use the source command as in "source @PATH_TO_THE_FILE" (this does not work)? Thanks.
– aloplop85
Jul 25 '13 at 13:38
1
Hi, you helped me with your answer! Thanks a lot! =)
– Daniel Garcia Sanchez
Jul 1 '15 at 13:22
add a comment |
Just use the absolute path of the file and then, instead of using backslashes, use forward slashes.
Example:
with backslashes : source C:folder1metropolises.sql
with forward slashes : source C:/folder1/metropolises.sql
1
Do you know if it is possible to store the path in a global or local variable (e.g @PATH_TO_THE_FILE) and use the source command as in "source @PATH_TO_THE_FILE" (this does not work)? Thanks.
– aloplop85
Jul 25 '13 at 13:38
1
Hi, you helped me with your answer! Thanks a lot! =)
– Daniel Garcia Sanchez
Jul 1 '15 at 13:22
add a comment |
Just use the absolute path of the file and then, instead of using backslashes, use forward slashes.
Example:
with backslashes : source C:folder1metropolises.sql
with forward slashes : source C:/folder1/metropolises.sql
Just use the absolute path of the file and then, instead of using backslashes, use forward slashes.
Example:
with backslashes : source C:folder1metropolises.sql
with forward slashes : source C:/folder1/metropolises.sql
edited Feb 17 '14 at 16:38
Alan
7731720
7731720
answered Jun 6 '13 at 7:19
chadchad
6572915
6572915
1
Do you know if it is possible to store the path in a global or local variable (e.g @PATH_TO_THE_FILE) and use the source command as in "source @PATH_TO_THE_FILE" (this does not work)? Thanks.
– aloplop85
Jul 25 '13 at 13:38
1
Hi, you helped me with your answer! Thanks a lot! =)
– Daniel Garcia Sanchez
Jul 1 '15 at 13:22
add a comment |
1
Do you know if it is possible to store the path in a global or local variable (e.g @PATH_TO_THE_FILE) and use the source command as in "source @PATH_TO_THE_FILE" (this does not work)? Thanks.
– aloplop85
Jul 25 '13 at 13:38
1
Hi, you helped me with your answer! Thanks a lot! =)
– Daniel Garcia Sanchez
Jul 1 '15 at 13:22
1
1
Do you know if it is possible to store the path in a global or local variable (e.g @PATH_TO_THE_FILE) and use the source command as in "source @PATH_TO_THE_FILE" (this does not work)? Thanks.
– aloplop85
Jul 25 '13 at 13:38
Do you know if it is possible to store the path in a global or local variable (e.g @PATH_TO_THE_FILE) and use the source command as in "source @PATH_TO_THE_FILE" (this does not work)? Thanks.
– aloplop85
Jul 25 '13 at 13:38
1
1
Hi, you helped me with your answer! Thanks a lot! =)
– Daniel Garcia Sanchez
Jul 1 '15 at 13:22
Hi, you helped me with your answer! Thanks a lot! =)
– Daniel Garcia Sanchez
Jul 1 '15 at 13:22
add a comment |
Related issue I had getting error 2 running source command: filename must not be in quotes even if it contains spaces in name or path to file.
Ah, this was my problem, thanks!
– sage88
Aug 5 '14 at 19:58
One tends to think that with spaces in the path quotes are necessary. What a headache!
– PavoDive
Mar 31 '16 at 11:40
add a comment |
Related issue I had getting error 2 running source command: filename must not be in quotes even if it contains spaces in name or path to file.
Ah, this was my problem, thanks!
– sage88
Aug 5 '14 at 19:58
One tends to think that with spaces in the path quotes are necessary. What a headache!
– PavoDive
Mar 31 '16 at 11:40
add a comment |
Related issue I had getting error 2 running source command: filename must not be in quotes even if it contains spaces in name or path to file.
Related issue I had getting error 2 running source command: filename must not be in quotes even if it contains spaces in name or path to file.
answered Feb 2 '14 at 8:40
user1906580user1906580
18414
18414
Ah, this was my problem, thanks!
– sage88
Aug 5 '14 at 19:58
One tends to think that with spaces in the path quotes are necessary. What a headache!
– PavoDive
Mar 31 '16 at 11:40
add a comment |
Ah, this was my problem, thanks!
– sage88
Aug 5 '14 at 19:58
One tends to think that with spaces in the path quotes are necessary. What a headache!
– PavoDive
Mar 31 '16 at 11:40
Ah, this was my problem, thanks!
– sage88
Aug 5 '14 at 19:58
Ah, this was my problem, thanks!
– sage88
Aug 5 '14 at 19:58
One tends to think that with spaces in the path quotes are necessary. What a headache!
– PavoDive
Mar 31 '16 at 11:40
One tends to think that with spaces in the path quotes are necessary. What a headache!
– PavoDive
Mar 31 '16 at 11:40
add a comment |
I first reach to the file
c:windows>cd c:akuraDb Scripts
c:akuraDb Scripts>mysql -u root -p root
mysql>. EXECUTER_NEW_USER.sql
here EXECUTER_NEW_USER.sql my file name
add a comment |
I first reach to the file
c:windows>cd c:akuraDb Scripts
c:akuraDb Scripts>mysql -u root -p root
mysql>. EXECUTER_NEW_USER.sql
here EXECUTER_NEW_USER.sql my file name
add a comment |
I first reach to the file
c:windows>cd c:akuraDb Scripts
c:akuraDb Scripts>mysql -u root -p root
mysql>. EXECUTER_NEW_USER.sql
here EXECUTER_NEW_USER.sql my file name
I first reach to the file
c:windows>cd c:akuraDb Scripts
c:akuraDb Scripts>mysql -u root -p root
mysql>. EXECUTER_NEW_USER.sql
here EXECUTER_NEW_USER.sql my file name
edited Feb 4 '14 at 11:07
Robert
4,0651252106
4,0651252106
answered Feb 4 '14 at 10:48
user3030395user3030395
4914
4914
add a comment |
add a comment |
It's probably the file path to your file. If you don't know the exact location of the file you want to use, try to find your file in Finder, then drag the file into Terminal window
mysql> SOURCE dragfilePathHere
add a comment |
It's probably the file path to your file. If you don't know the exact location of the file you want to use, try to find your file in Finder, then drag the file into Terminal window
mysql> SOURCE dragfilePathHere
add a comment |
It's probably the file path to your file. If you don't know the exact location of the file you want to use, try to find your file in Finder, then drag the file into Terminal window
mysql> SOURCE dragfilePathHere
It's probably the file path to your file. If you don't know the exact location of the file you want to use, try to find your file in Finder, then drag the file into Terminal window
mysql> SOURCE dragfilePathHere
answered Apr 13 '17 at 5:33
Michelle DaiMichelle Dai
512
512
add a comment |
add a comment |
I've had the same error on Windows.
I solved it with (after on cmd: mysql -u root):
mysql> SOURCE C:/users/xxx/xxxx/metropolises.sql;
Be sure you type the right file path
add a comment |
I've had the same error on Windows.
I solved it with (after on cmd: mysql -u root):
mysql> SOURCE C:/users/xxx/xxxx/metropolises.sql;
Be sure you type the right file path
add a comment |
I've had the same error on Windows.
I solved it with (after on cmd: mysql -u root):
mysql> SOURCE C:/users/xxx/xxxx/metropolises.sql;
Be sure you type the right file path
I've had the same error on Windows.
I solved it with (after on cmd: mysql -u root):
mysql> SOURCE C:/users/xxx/xxxx/metropolises.sql;
Be sure you type the right file path
edited Jun 12 '14 at 17:09
Ante
4,39451942
4,39451942
answered Jun 12 '14 at 16:47
Alex_AleluiaAlex_Aleluia
294
294
add a comment |
add a comment |
If you are using vagrant ensure that the file is on the server and then use the path to the file. e.g if the file is stored in the public folder you will have
sql> source /var/www/public/xxx.sql
Where xxx is the name of the file
add a comment |
If you are using vagrant ensure that the file is on the server and then use the path to the file. e.g if the file is stored in the public folder you will have
sql> source /var/www/public/xxx.sql
Where xxx is the name of the file
add a comment |
If you are using vagrant ensure that the file is on the server and then use the path to the file. e.g if the file is stored in the public folder you will have
sql> source /var/www/public/xxx.sql
Where xxx is the name of the file
If you are using vagrant ensure that the file is on the server and then use the path to the file. e.g if the file is stored in the public folder you will have
sql> source /var/www/public/xxx.sql
Where xxx is the name of the file
answered Aug 5 '17 at 21:42
Ibrahim IsaIbrahim Isa
11112
11112
add a comment |
add a comment |
I got this error in mysql command line using this query:
source `db.sql`;
I changed the above to the following to make it work:
source db.sql;
add a comment |
I got this error in mysql command line using this query:
source `db.sql`;
I changed the above to the following to make it work:
source db.sql;
add a comment |
I got this error in mysql command line using this query:
source `db.sql`;
I changed the above to the following to make it work:
source db.sql;
I got this error in mysql command line using this query:
source `db.sql`;
I changed the above to the following to make it work:
source db.sql;
answered Jun 29 '15 at 8:58
Ciuc lpgfmkCiuc lpgfmk
1531212
1531212
add a comment |
add a comment |
On my windows 8.1, and mysql 5.7.9 MySQL Community Server (GPL),
I had to remove the ;
after the file path.
This failed: source E:/jokoni/db/Banking/createTables.sql;
This Worked: source E:/jokoni/db/Banking/createTables.sql
(without termination, and forward slashes instead of windows' backslashes in path)
Same as you, but I wonder why?
– Akshat Agarwal
Jan 16 '16 at 5:43
add a comment |
On my windows 8.1, and mysql 5.7.9 MySQL Community Server (GPL),
I had to remove the ;
after the file path.
This failed: source E:/jokoni/db/Banking/createTables.sql;
This Worked: source E:/jokoni/db/Banking/createTables.sql
(without termination, and forward slashes instead of windows' backslashes in path)
Same as you, but I wonder why?
– Akshat Agarwal
Jan 16 '16 at 5:43
add a comment |
On my windows 8.1, and mysql 5.7.9 MySQL Community Server (GPL),
I had to remove the ;
after the file path.
This failed: source E:/jokoni/db/Banking/createTables.sql;
This Worked: source E:/jokoni/db/Banking/createTables.sql
(without termination, and forward slashes instead of windows' backslashes in path)
On my windows 8.1, and mysql 5.7.9 MySQL Community Server (GPL),
I had to remove the ;
after the file path.
This failed: source E:/jokoni/db/Banking/createTables.sql;
This Worked: source E:/jokoni/db/Banking/createTables.sql
(without termination, and forward slashes instead of windows' backslashes in path)
answered Nov 25 '15 at 5:22
LivePwndzLivePwndz
332511
332511
Same as you, but I wonder why?
– Akshat Agarwal
Jan 16 '16 at 5:43
add a comment |
Same as you, but I wonder why?
– Akshat Agarwal
Jan 16 '16 at 5:43
Same as you, but I wonder why?
– Akshat Agarwal
Jan 16 '16 at 5:43
Same as you, but I wonder why?
– Akshat Agarwal
Jan 16 '16 at 5:43
add a comment |
May be the file name or path you are used may be incorrect
In my system i created file abcd.sql at c:
and used command mysql> source c:abcd.sql
Then i got result
Actually, I'm doing it on ssh. How to view the directories of the files created on a particular database?
– Clueless Gorilla
Feb 4 '13 at 10:24
@PengHuiHow - do you know the actual path of that file?
– Fathah Rehman P
Feb 4 '13 at 10:42
add a comment |
May be the file name or path you are used may be incorrect
In my system i created file abcd.sql at c:
and used command mysql> source c:abcd.sql
Then i got result
Actually, I'm doing it on ssh. How to view the directories of the files created on a particular database?
– Clueless Gorilla
Feb 4 '13 at 10:24
@PengHuiHow - do you know the actual path of that file?
– Fathah Rehman P
Feb 4 '13 at 10:42
add a comment |
May be the file name or path you are used may be incorrect
In my system i created file abcd.sql at c:
and used command mysql> source c:abcd.sql
Then i got result
May be the file name or path you are used may be incorrect
In my system i created file abcd.sql at c:
and used command mysql> source c:abcd.sql
Then i got result
answered Feb 4 '13 at 10:00
Fathah Rehman PFathah Rehman P
6,02733136
6,02733136
Actually, I'm doing it on ssh. How to view the directories of the files created on a particular database?
– Clueless Gorilla
Feb 4 '13 at 10:24
@PengHuiHow - do you know the actual path of that file?
– Fathah Rehman P
Feb 4 '13 at 10:42
add a comment |
Actually, I'm doing it on ssh. How to view the directories of the files created on a particular database?
– Clueless Gorilla
Feb 4 '13 at 10:24
@PengHuiHow - do you know the actual path of that file?
– Fathah Rehman P
Feb 4 '13 at 10:42
Actually, I'm doing it on ssh. How to view the directories of the files created on a particular database?
– Clueless Gorilla
Feb 4 '13 at 10:24
Actually, I'm doing it on ssh. How to view the directories of the files created on a particular database?
– Clueless Gorilla
Feb 4 '13 at 10:24
@PengHuiHow - do you know the actual path of that file?
– Fathah Rehman P
Feb 4 '13 at 10:42
@PengHuiHow - do you know the actual path of that file?
– Fathah Rehman P
Feb 4 '13 at 10:42
add a comment |
If you're on Debian 8 (Jessie) Linux, try to cd
into the directory of the 'metropolises.sql'
. Run mysql
and execute SOURCE ./metropolises.sql;
Basically, try the relative path. I tried this and it works.
add a comment |
If you're on Debian 8 (Jessie) Linux, try to cd
into the directory of the 'metropolises.sql'
. Run mysql
and execute SOURCE ./metropolises.sql;
Basically, try the relative path. I tried this and it works.
add a comment |
If you're on Debian 8 (Jessie) Linux, try to cd
into the directory of the 'metropolises.sql'
. Run mysql
and execute SOURCE ./metropolises.sql;
Basically, try the relative path. I tried this and it works.
If you're on Debian 8 (Jessie) Linux, try to cd
into the directory of the 'metropolises.sql'
. Run mysql
and execute SOURCE ./metropolises.sql;
Basically, try the relative path. I tried this and it works.
answered Mar 31 '16 at 23:10
T. WebsterT. Webster
4,61045184
4,61045184
add a comment |
add a comment |
If you are running dockerized MySQL container such as ones from this official Docker Image registry: https://hub.docker.com/_/mysql/ You may encounter this issue as well.
add a comment |
If you are running dockerized MySQL container such as ones from this official Docker Image registry: https://hub.docker.com/_/mysql/ You may encounter this issue as well.
add a comment |
If you are running dockerized MySQL container such as ones from this official Docker Image registry: https://hub.docker.com/_/mysql/ You may encounter this issue as well.
If you are running dockerized MySQL container such as ones from this official Docker Image registry: https://hub.docker.com/_/mysql/ You may encounter this issue as well.
answered May 11 '16 at 15:33
DevyDevy
5,08323745
5,08323745
add a comment |
add a comment |
For me it was because the file was located on a shared drive and it could not access, for some reason, to that path.
I cut the file and put it on my local drive in a path without spaces and it got resolved.
add a comment |
For me it was because the file was located on a shared drive and it could not access, for some reason, to that path.
I cut the file and put it on my local drive in a path without spaces and it got resolved.
add a comment |
For me it was because the file was located on a shared drive and it could not access, for some reason, to that path.
I cut the file and put it on my local drive in a path without spaces and it got resolved.
For me it was because the file was located on a shared drive and it could not access, for some reason, to that path.
I cut the file and put it on my local drive in a path without spaces and it got resolved.
answered Dec 7 '17 at 20:48
CamiloCamilo
1069
1069
add a comment |
add a comment |
I got the same error when i used the command source and gave the sql file path by drag n dropping it.
Then I just had to remove those single quotes which appeared by default with drag and drop, a space before file extension and it worked.
soln:
source /home/xyz/file .sql ;(path and a space before file extension)
add a comment |
I got the same error when i used the command source and gave the sql file path by drag n dropping it.
Then I just had to remove those single quotes which appeared by default with drag and drop, a space before file extension and it worked.
soln:
source /home/xyz/file .sql ;(path and a space before file extension)
add a comment |
I got the same error when i used the command source and gave the sql file path by drag n dropping it.
Then I just had to remove those single quotes which appeared by default with drag and drop, a space before file extension and it worked.
soln:
source /home/xyz/file .sql ;(path and a space before file extension)
I got the same error when i used the command source and gave the sql file path by drag n dropping it.
Then I just had to remove those single quotes which appeared by default with drag and drop, a space before file extension and it worked.
soln:
source /home/xyz/file .sql ;(path and a space before file extension)
edited Jan 24 '18 at 10:30
answered Jan 24 '18 at 6:41
maithri poojarymaithri poojary
13
13
add a comment |
add a comment |
For Mac users, you can give the path as,
source /Users/YOUR_USER_NAME/Desktop/metropolises.sql;
*I have assumed that the file you need to source
is in your desktop
and the file name is metropolises.sql
If you type,
source metropolises.sql
then the file will be look in the default location,
/Users/YOUR_USER_NAME/metropolises.sql;
add a comment |
For Mac users, you can give the path as,
source /Users/YOUR_USER_NAME/Desktop/metropolises.sql;
*I have assumed that the file you need to source
is in your desktop
and the file name is metropolises.sql
If you type,
source metropolises.sql
then the file will be look in the default location,
/Users/YOUR_USER_NAME/metropolises.sql;
add a comment |
For Mac users, you can give the path as,
source /Users/YOUR_USER_NAME/Desktop/metropolises.sql;
*I have assumed that the file you need to source
is in your desktop
and the file name is metropolises.sql
If you type,
source metropolises.sql
then the file will be look in the default location,
/Users/YOUR_USER_NAME/metropolises.sql;
For Mac users, you can give the path as,
source /Users/YOUR_USER_NAME/Desktop/metropolises.sql;
*I have assumed that the file you need to source
is in your desktop
and the file name is metropolises.sql
If you type,
source metropolises.sql
then the file will be look in the default location,
/Users/YOUR_USER_NAME/metropolises.sql;
edited Nov 24 '18 at 6:36
answered Nov 24 '18 at 6:26
Nadun KulatungeNadun Kulatunge
7542822
7542822
add a comment |
add a comment |
The solution for me was file permissions in Windows. Just give full control in the file to all users and it will work. After the import, get the permissions back to what it was before.
add a comment |
The solution for me was file permissions in Windows. Just give full control in the file to all users and it will work. After the import, get the permissions back to what it was before.
add a comment |
The solution for me was file permissions in Windows. Just give full control in the file to all users and it will work. After the import, get the permissions back to what it was before.
The solution for me was file permissions in Windows. Just give full control in the file to all users and it will work. After the import, get the permissions back to what it was before.
answered Jan 13 at 10:44
Ricardo BRGWebRicardo BRGWeb
7751020
7751020
add a comment |
add a comment |
On my Mac, this is the only solution worked for me.
https://stackoverflow.com/a/45530305/5414448
1 - Download the .sql file and remember it's location.
2 - Open your mysql from command prompt or terminal.
3 - Create a database with the same name as that of the database present in the .sql file (create database your_database_name)
4 - Now exit out from the mysql command line client
5 - Now try and execute this command =>
mysql -u your_username -p your_database_name < your_sql_file_with_complete_location
example - mysql -u root -p trial < /home/abc/Desktop/trial.sql
here my .sql file is named trial and is present in the desktop, the database is also name trial
6 - You should now have your sql file imported to the corresponding mysql database.
add a comment |
On my Mac, this is the only solution worked for me.
https://stackoverflow.com/a/45530305/5414448
1 - Download the .sql file and remember it's location.
2 - Open your mysql from command prompt or terminal.
3 - Create a database with the same name as that of the database present in the .sql file (create database your_database_name)
4 - Now exit out from the mysql command line client
5 - Now try and execute this command =>
mysql -u your_username -p your_database_name < your_sql_file_with_complete_location
example - mysql -u root -p trial < /home/abc/Desktop/trial.sql
here my .sql file is named trial and is present in the desktop, the database is also name trial
6 - You should now have your sql file imported to the corresponding mysql database.
add a comment |
On my Mac, this is the only solution worked for me.
https://stackoverflow.com/a/45530305/5414448
1 - Download the .sql file and remember it's location.
2 - Open your mysql from command prompt or terminal.
3 - Create a database with the same name as that of the database present in the .sql file (create database your_database_name)
4 - Now exit out from the mysql command line client
5 - Now try and execute this command =>
mysql -u your_username -p your_database_name < your_sql_file_with_complete_location
example - mysql -u root -p trial < /home/abc/Desktop/trial.sql
here my .sql file is named trial and is present in the desktop, the database is also name trial
6 - You should now have your sql file imported to the corresponding mysql database.
On my Mac, this is the only solution worked for me.
https://stackoverflow.com/a/45530305/5414448
1 - Download the .sql file and remember it's location.
2 - Open your mysql from command prompt or terminal.
3 - Create a database with the same name as that of the database present in the .sql file (create database your_database_name)
4 - Now exit out from the mysql command line client
5 - Now try and execute this command =>
mysql -u your_username -p your_database_name < your_sql_file_with_complete_location
example - mysql -u root -p trial < /home/abc/Desktop/trial.sql
here my .sql file is named trial and is present in the desktop, the database is also name trial
6 - You should now have your sql file imported to the corresponding mysql database.
answered Jan 14 at 3:57
Andrew RhyneAndrew Rhyne
33
33
add a comment |
add a comment |
Remove spaces in the folder names of the path, It worked for my mac path.
(Eg: change the folder name MySQL Server 5.1 to MySQLServer5.1)
add a comment |
Remove spaces in the folder names of the path, It worked for my mac path.
(Eg: change the folder name MySQL Server 5.1 to MySQLServer5.1)
add a comment |
Remove spaces in the folder names of the path, It worked for my mac path.
(Eg: change the folder name MySQL Server 5.1 to MySQLServer5.1)
Remove spaces in the folder names of the path, It worked for my mac path.
(Eg: change the folder name MySQL Server 5.1 to MySQLServer5.1)
answered Mar 10 '15 at 9:16
LoganathanLoganathan
923815
923815
add a comment |
add a comment |
I also got the same message when I try from the MySQL console. However, when I open the command prompt and do the same steps it works.
C:UsersSubhenduD>cd ../
C:Users>cd ../
C:>cd xamppmysqlbin
C:xamppmysqlbin>mysql -u -root
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 68
Server version: 5.6.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> use balticktravels;
mysql> source balticktravels.sql;
add a comment |
I also got the same message when I try from the MySQL console. However, when I open the command prompt and do the same steps it works.
C:UsersSubhenduD>cd ../
C:Users>cd ../
C:>cd xamppmysqlbin
C:xamppmysqlbin>mysql -u -root
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 68
Server version: 5.6.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> use balticktravels;
mysql> source balticktravels.sql;
add a comment |
I also got the same message when I try from the MySQL console. However, when I open the command prompt and do the same steps it works.
C:UsersSubhenduD>cd ../
C:Users>cd ../
C:>cd xamppmysqlbin
C:xamppmysqlbin>mysql -u -root
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 68
Server version: 5.6.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> use balticktravels;
mysql> source balticktravels.sql;
I also got the same message when I try from the MySQL console. However, when I open the command prompt and do the same steps it works.
C:UsersSubhenduD>cd ../
C:Users>cd ../
C:>cd xamppmysqlbin
C:xamppmysqlbin>mysql -u -root
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 68
Server version: 5.6.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> use balticktravels;
mysql> source balticktravels.sql;
edited Nov 25 '18 at 7:26
Petro
1,86721533
1,86721533
answered Sep 12 '16 at 5:40
subhendu dassubhendu das
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14684063%2fmysql-source-error-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What does it mean to "try to source for a particuar .sql file"?
– Lightness Races in Orbit
Feb 4 '13 at 9:51
1
Did you mean "search"?
– veljasije
Feb 4 '13 at 9:54
I created a table in a database. Now, in order to get the data created, I typed SOURCE metropolises.sql; into the terminal, however the error message as described above showed up. Pretty sure there's no error in the table created.
– Clueless Gorilla
Feb 4 '13 at 10:22