For running SQL scripts, you can run the regular mysql command in combination with the program cat
.
This is also a method of retrieving backup
made with mysqldump
. If so, make sure the tables are not already existing. Also see the Database administrasjon in MySQL documentation.
cat filename.sql | mysql DATABASE NAME -uUSERNAME -hDATABASE NAME.mysql.domeneshop.no -p
You will be asked for your MySQL password. If you need to automate this, you may consider creating a .my.cnf
file with your password. Make sure that the file is readable onlyfor your own Unix user! You may read more about MySQL password security here.
If the file is zipped with gzip:
zcat filename.sql.gz | mysql DATABASE NAME -uUSERNAME -hDATABASE NAME.mysql.domeneshop.no -p
Substitute file name.sql
or file name.sql.gz
with the file name of your SQL script.