Run a series of commands with mysql

Mysql

From the command line, use

hostname:$ mysql -u username -p -Ddb_name < mysql_cmds.txt

When creating tables its often useful to do CREATE TABLE IF NOT EXISTS table_name as bugs can pop up in scripts and recreating a table that's already there causes an error.

Note: To run a single command, invoke

mysql -e 'use db; show tables;'>

Comments powered by Disqus

Copyright 2010. All Rights Reserved.