What is the proper method to execute an SQL file in MySQL?

I’m attempting to run a series of SQL commands stored in a text file using MySQL, but I’m encountering issues. I used the command below in the MySQL shell:

RUN_SQL /Documents/new_script.sql

However, I received an error message like:

mysql> : \data\user\Documents\new_script.sql
ERROR: Unable to open file '\data\user\Documents\new_script.sql'

I’ve tried several approaches and still face the problem. Can anyone clarify what I might be doing incorrectly and suggest the correct syntax or method to run the SQL file?

The correct approach when running an SQL file in MySQL involves using the appropriate command within the MySQL prompt rather than a custom or incorrect command. When connected to the MySQL shell, the command to execute a script is source followed by the complete file path. This command was effective in my experience and ensured that the file was correctly located and executed by MySQL. It is preferable to check that the file path uses the proper directory separators for your operating system and that the SQL file has the appropriate permissions to be read.

hey, try source with the full path. sometimes forgetting the exact file path or permission issues causes probs. rough it out with the correct directory separators depending on your os