The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-01-2008
ankimo ankimo is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 23
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
i wonder if anyone can provide some guidance.

thanks.
  #2 (permalink)  
Old 10-01-2008
ankimo ankimo is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 23
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
  #3 (permalink)  
Old 10-01-2008
ankimo ankimo is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 23
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0