0

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.

JustEngland
  • 1,371
  • 13
  • 30
  • I was able to get the out of the box mysql client to work with a little coercion. Step 1: Get hostname, use the mysql-ctl tool to get the host name. mysql> SHOW VARIABLES WHERE Variable_name = 'hostname' Step 2: use the normal mysql client to execute a script $>mysql -u {{username}} -h {{hostname}} {{database}} < sample.sql – JustEngland Aug 10 '14 at 14:53
  • 1
    You cannot use mysql-ctl to execute the script but you can use the usual mysql command: `mysql -h 127.0.0.1 -u username < yourfile.sql` – lcipriani Aug 11 '14 at 08:47
  • You are write, if you answer the question, I will approve it. – JustEngland Aug 11 '14 at 18:32

2 Answers2

2

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
lcipriani
  • 363
  • 2
  • 7
1

When you are in 'mysql-ctl' just run source file_name.sql and your script will run.