grant usage to users listed in a file


 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications grant usage to users listed in a file
# 1  
Old 10-01-2008
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  
Old 10-01-2008
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  
Old 10-01-2008
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

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Emergency UNIX and Linux Support

Usage by users

I would like to know how to capture the usage of CPU by each user. Is there a way to do this on AIX? Gaya (0 Replies)
Discussion started by: ggayathri
0 Replies

2. Shell Programming and Scripting

Space usage by top 5 users in a filesystem

I want to see top 5 users,who have occupied most amount of disk space in a filesystem. But not sure how to do it. I can get the usage for a particular user find . -user user -type f exec df -h {} \;|awk '{ s = s+$1 } END { print "Total used: ",s }' But how to get without specifying any user... (6 Replies)
Discussion started by: rka
6 Replies

3. AIX

High CPU Usage , users affected

Dear All, One production Server is affected by high usage. Application is slow now. Please guide me how to solve it? NMON Report shows full cpu usage. Here im posting some server details. bash-3.2# lparstat -i Node Name : ********* Partition Name ... (6 Replies)
Discussion started by: Thala
6 Replies

4. Shell Programming and Scripting

Users and their storage usage

Hey, I'm trying to make a script that can list users and their storage usage in a file. Im trying to get it to where the format is: User xxkbs User2 xkb and so on. So far I figured out how to get the users, but I cannot figure out how to get the storage usage per user. This is what... (2 Replies)
Discussion started by: HakerDemon
2 Replies

5. UNIX for Dummies Questions & Answers

CPU usage restrictions for users?

I was wondering if there was a way to set resource usage per user. For example, if I use "grep -f <file1> <file2>" and the two files are very big it consumes a lot of resources. Onetime someone pinged me and asked what the hell I was doing and to kill it. Is there any way an SA can restrict... (7 Replies)
Discussion started by: MaindotC
7 Replies

6. AIX

balance CPU usage between users

Hi! Is there any way to balance CPU usage between users on percentage basis? Something like Resource Manager in Oracle databases. Regards. ---------- Post updated at 02:17 PM ---------- Previous update was at 02:09 PM ---------- Workload Manager? ---------- Post updated at 03:44 PM... (0 Replies)
Discussion started by: bas_ua
0 Replies

7. UNIX for Advanced & Expert Users

any quicker way to list disc usage by users?

Hi: it takes a long time for "du -sh list_of_users" to give you the output. Is there a quicker way to get this info? Thanks! N.B. Phil (4 Replies)
Discussion started by: phil518
4 Replies

8. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

9. UNIX for Dummies Questions & Answers

memory usage : kernel, oracle, other users

Hello, I'm looking for a command or script that could permit me to know what is memory usage group by HP-UX kernel, oracle processes and other users (specific software). A command like 'top' but for all processes and not only for 12 max could be very useful Thanks in advance (4 Replies)
Discussion started by: thierryUX
4 Replies

10. HP-UX

CVSWeb - Directories listed but files not listed

I am using CVSWeb on HPUnix. When i access it, all directories are listed but files are not listed. I am getting the error "NOTE: There are 51 files, but none matches the current tag. " in tomcat sevrer log i am getting the message "rlog warning: Missing revision or branch number after -r"... (0 Replies)
Discussion started by: ganesh
0 Replies
Login or Register to Ask a Question