Search code examples
mysqlcloud9-ide

How do you execute a sql file using mysql-ctl


I am learning how to use mysql with Cloud9, I have a script used to create a default database and tables and loading sample data into the new database. How do I use the mysql-ctl tool to execute a script file?

It connects to a database just fine and I can execute ad-hoc queries without an issue.


Solution

  • You cannot use mysql-ctl to execute the script (you can see the source code running less $(which mysql-ctl) but you can use the usual mysql client command:

    mysql -h 127.0.0.1 -u username < yourfile.sql