Rob, use your imagination: this is a case for a quick and dirty shell script. You don't have blanks in your usernames, do you? Try something like this: (no guarantee that it works)
#!/bin/sh # fetch users from a table and create databases # creates a new table with preliminary passwords for those users HOST="localhost" # where all your users reside DBASE=test # set yours USERTABLE=yourtablewithusernames OPTS="" # options to access your database MYSQL="mysql -N $OPTS $DBASE" # add any further options here echo "CREATE TABLE IF NOT EXISTS usrpwd(\ user VARCHAR(255), pwd VARCHAR(13));" | $MYSQL USERS="$(echo "SELECT user_name FROM $USERTABLE;" | $MYSQL)" for USER in $USERS ; do echo -n "User $USER" if ! mysqladmin $OPTS create $USER ; then echo -e "\nfailed to create database for '$USER'" exit 1 fi PW=$(echo "SELECT ENCRYPT('$USER');" | $MYSQL) if ! echo "GRANT ALL ON $USER.* TO '$USER'@'$HOST' \ IDENTIFIED BY '$PW' WITH GRANT OPTION;" \ | $MYSQL ; then echo -e "\nfailed to GRANT rights for '$USER'" exit 1 else echo " has Password '$PW'" echo "INSERT INTO usrpwd VALUES('$USER','$PW');" \ | $MYSQL fi done echo "SELECT * FROM usrpwd ORDER BY user;" | $MYSQL # this is the end of the shell script Have fun Thomas Spahni On Tue, 7 Sep 2004, Rob Keeling wrote: > Having googled extensively, I can`t seem to find a way to do the following. > > I have a mysql table, with around 1200 usernames in it. > > What I want to do is programmatically add each user, and create a database > of the same name > that that user has access to. > > (This is for a school web server, we want to allow students to try out mysql > querys with phpmyadm etc) > > Any suggestions? > > Thanks > > Rob Keeling > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]