----- Original Message ----- 
From: "Brian C. Hill" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 16, 2004 4:22 PM
Subject: grants to multiple DBs at once


> I have about 20 DB's with the same prefix.
>
> How can I do something like
>
> GRANT SELECT ON dev_*.* ....
>
> I have seen examples for the _other_ DB software, like msql,
> that does something like:
>
> SELECT 'GRANT SELECT ON '+name+' TO webuser;'
> from sysobjects
> where type = 'U'
>
> (which generates the grant statements to run)
>
> Is this possible in mysql? Maybe something like:
>
> SELECT 'GRANT SELECT ON '+name+' TO webuser;'
> from `show databases like 'dev_%'`
>
> I know that sub-queries aren't possible, but does anyone have
> any suggestions that don't involve weighty shell scripts?
>
> Is there anyway to write show databases to file
> without the bordering box?
>
I don't know what you mean by "weighty" but this code excerpt is from a Bash
shell script that I use for taking database backups. The 'for' line can
probably be adapted to do what you want; it writes the names of all of the
databases to the variable ONE_DBNAME:

USERID="foo"; #The userid to use for creating the backup
PASSWORD="bar"; #The password to use for creating the backup

#For each database currently in MySQL, take a database-level backup.
for ONE_DBNAME in `echo show databases | mysql -s -u $USERID -p$PASSWORD`
do
   echo
   echo "Backing up database" $ONE_DBNAME;
# do whatever you want to do
done

Rhino


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to