In codeAnywhere I'm trying to run pre written script files to create a table. When using codeAnywhere one must import the file to the shell for the code first, as I have done. However I have been unable to use the SOURCE
command to run these files. I have currently attempted this syntax:
USE exams SOURCE students.txt;
What is the correct syntax here? Do I need to name the database in the syntax? Are there other commands which run text files containing code?
EDIT: I tried using this syntax, to the following result:
ERROR: Failed to open file 'exams(question5.txt)', error: 2
On the shell you can use the following command to execute the queries from a text file:
mysql db_name < text_file
Hint: If the USE
command (with correct database name) is specified on the textfile you don't need to specify the database. The SOURCE
command is not available on MySQL instead you need the <
.
You can find more information about executing queries from text files here: https://dev.mysql.com/doc/refman/5.7/en/mysql-batch-commands.html