Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

Execute SQL query from Command Line

mysql-newbie's profile image mysql-newbie posted 4 years ago in Running SQL scripts Permalink

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's profile image ansgar posted 4 years ago Permalink

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

mysql-newbie's profile image mysql-newbie posted 4 years ago Permalink

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's profile image ansgar posted 4 years ago Permalink

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's profile image mysql-newbie posted 4 years ago Permalink

Will do. Thanks for the help!

ducpham's profile image ducpham posted 4 years ago Permalink

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

Thanks for the help @Ansgar. A stupid question, once the SQL command is executed on the server via SSH client, how do we get the output files back to our computer?

In this case I am automating some SELECT INTO OUTFILE lines.

Thanks!

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




Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.