I have a Mysql database dump. I want to install it with Hudson via a Shell Script to an external Linux machine.How can you take a Mysql script and run it inside a database on other machine? I know I can transfer files with sftp and use ssh when accessing another machines manually, but how to automate this all to a simple Shell Script?
How to install a database dump via Shell Script?
shell script;mysql;remote
$ mysql -p$pass -u$user -h$otherhost $db < dumpfileThis assumes dumpfile is text from mysqldump, containing raw SQL statements.It is important that there be no space between -p and the password. (I assume you want automatic login.) If the password does not immediately follow the -p, mysql interprets the option as meaning it should ask interactively for the password, and treats the separate password argument as the DB name.For this to work, $user must have permission to log in, drop a table, create a table, and insert rows into that table, all as a remote user. MySQL keeps separate remote and local permissions for users, so this is an easy trap to fall into. Because allowing a remote user this much power is a security risk, you may want to use SSL (--ssl* options) with mysql. Otherwise, I don't know that I would allow a remote user to do such things.