Frequently asked questions


How do I run an SQL script?

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 -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 -p

Substitute file name.sql or file name.sql.gz with the file name of your SQL script.

See also:

© 2024 Domeneshop AS · About us · Terms · Privacy policy