Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql: SOURCE error 2?

Tags:

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?

like image 292
Clueless Gorilla Avatar asked Feb 04 '13 09:02

Clueless Gorilla


People also ask

What is source command in MySQL?

If you are already running mysql, you can execute an SQL script file using the source command or \. command: mysql> source file_name mysql> \. file_name. Sometimes you may want your script to display progress information to the user.

What is MySQL Error 22?

This means there are too many open files or connections to mysql and it can't handle the request to open another mysql file.


2 Answers

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.

like image 143
Lightness Races in Orbit Avatar answered Oct 14 '22 05:10

Lightness Races in Orbit


Just use the absolute path of the file and then, instead of using backslashes, use forward slashes.

Example:

with backslashes : source C:\folder1\metropolises.sql
with forward slashes : source C:/folder1/metropolises.sql

like image 38
chad Avatar answered Oct 14 '22 05:10

chad