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:
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
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:
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