Following are a couple of ways to execute SQL on a remote MySQL server via the shell.
Executing SQL directly from the command line:
$ mysql -u uid -p -h remote.host database -e ‘SQL query here;’
Executing SQL from a file on the local host on the remote server:
$ mysql -u uid -p -h remote.host database < file.sql
You can also connect to the remote mysql server and from the command line execute SQL from files on the local → Continue reading “Executing MySQL Queries and Commands from the Command Line to a Remote Server”