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?
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.
This means there are too many open files or connections to mysql and it can't handle the request to open another mysql file.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With