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

Reply via email to