View Single Post
  #2  
Old 04-04-2002, 07:17 AM
theCoder
Sarnak
 
Join Date: Jan 2002
Posts: 90
Default

Excellent!

As a side note, for those of you running mysql on Linux, here's a script I've written that uses the information in your db.ini file to create and populate the database. It's meant to be run on the mysql server machine. It assumes the following things are already set up:
* db.ini is correct (correct username, password, database name) and the database name in db.ini isn't already in the database
* The data to populate the database is located in .sql files in a data subdirectory and they have no errors (like duplicate keys)

Anyway, here's the script:
Code:
$ cat makedb
#!/bin/bash

DBNAME=`cat db.ini | grep database | awk -F= '{print $2}'`
DBUSER=`cat db.ini | grep user     | awk -F= '{print $2}'`
DBPASS=`cat db.ini | grep password | awk -F= '{print $2}'`

# first create the DB
echo "Creating database $DBNAME... enter mysql root password if prompted"
echo \
"create database $DBNAME;
 grant all on $DBNAME.* TO $DBUSER IDENTIFIED BY '$DBPASS';" | mysql -uroot -p

# now populate it
echo "Populating database $DBNAME..."
cat data/*.sql | mysql -u$DBUSER -p$DBPASS $DBNAME