Mysql – Create multiple thesql users and databases

MySQL

Using mysql 5.5 on Ubuntu 12.04, what's the easiest way to create 30 new users with their own database?

I know how to use the create user command

Best Answer

Script it in bash, probably. Take a list of users, and do something like the following (you will need to modify this heavily):

for line in $ (cat users.txt) do
   mysql < create database $line;
   mysql < create user $line@localhost identified by defaultpassword;
   mysql < grant all privileges on $line to $line@'localhost;
done