You can put any mysql command into a simple file, then: mysql [database] < filename
-Rob On Wed, 2002-03-13 at 14:01, Kahli R. Burke wrote: > Bob Crandell wrote: > > >mysql -u root -p > >mysql> create database phpgroupware ; > >mysql> grant all on phpgroupware.* to phpgroupware@localhost identified by > >'password'; > >mysql> quit > > > >These are the lines to create a database and set a password. How would I put this > >in a shell script? I want it to run unattended, at least, almost unattended. > > > Because mysql is an interactive program, you either need to use > something like expect to interact with mysql for you, or put the > commands into a file and give it to mysql on the command line. I can't > remember what the option is to pass ina file with SQL commands, but > it's in there. If you need to substitute strings for the password or > something, you might have to use a token in your file like '$password' > or something and use sed to replace it with the real desired password... > > Kahli > -- Rob <rob_at_euglug_dot_net> my @euglugCode = qw(v+++ e--- eug+ bsd+++ gnu+ S+++);
