Execute SQL query from Command Line

mysql-newbie posted 2 weeks ago in Running SQL scripts

Is there a way to execute a SQL query from command line. For instance I use:

heidisql.exe -d=mysession "c:\test.sql"

And it opens heidisql and opens the query in the query tab but I want it to execute the query as well. Even better yet, if it could execute the query and then close heidisql that would be awesome.

Any help is much appreciated.

ansgar posted 2 weeks ago

You should use mysqldump for such purposes. See here for an example.

mysql-newbie posted 2 weeks ago

I don't have mysql installed on my local machine. I'm connecting from across the internet via SSH is there a way to do that or do I need a different program?

ansgar posted 2 weeks ago

Ok, then you could use an SSH client (Putty for example), connect to your MySQL server and then pass the commands you want to execute.

mysql-newbie posted 2 weeks ago

Will do. Thanks for the help!

Please login to leave a reply, or register at first.