![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MySQL GRANT permission. | mjdousti | UNIX for Dummies Questions & Answers | 0 | 01-15-2008 02:58 PM |
| memory usage : kernel, oracle, other users | thierryUX | UNIX for Dummies Questions & Answers | 4 | 09-18-2006 11:17 AM |
| CVSWeb - Directories listed but files not listed | ganesh | HP-UX | 0 | 09-16-2005 04:32 PM |
| Files listed Do not really exist | Ricky Raynor | UNIX for Advanced & Expert Users | 6 | 02-08-2002 05:20 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
grant usage to users listed in a file
hi,
i'm trying to grant usage to multiple users whose ids are in a file. i thought that i could put the mysql code within a while loop, but that's not working for me: Code:
while read user; do userid=$user passwd="changeme" query="grant usage on mysql.USERS.* to $userid identified by '$passwd'"; mysql -u<root> -p<password> $query; flush privileges; quit; done < userid_file thanks. |
|
||||
|
i thought about this some more and wonder if this is a smarter solution. it seems closer, but i'd still love feedback if there is a better way:
Code:
while read user; do userid=$user passwd="changeme" print "grant usage on <database>.* to '"$user"' identified by '"$passwd"';" >> grant_file done < userid_file mysql -BCNnqs --disable-pager -u<root> -p<password> <<EOJ source /PATH/to/grant_file flush privileges; quit; EOJ |
|
||||
|
for the other newbies, i made some dumb mistakes. the biggest was that i shouldn't have had a ; after quit. i think this is better:
Code:
while read user; do userid=$user passwd="changeme" mysql -u<root> -p<password> grant usage on *.* to '$userid' identified by '$passwd'; flush privileges; quit done < userid_file |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|