# vi mysqlusers.txt
create database dataname;
grant all privileges on dataname.* to username@localhost identified by ‘password‘;
flush privileges;
# /usr/local/mysql/bin/mysql -u root -p password < mysqlusers.txt
藍色斜體部分為對應的用戶名和密碼,添加多個用戶及數據庫,只需要復制中間部分代碼並修改對應的位置即可,如:
create database dataname1;
grant all privileges on dataname1.* to username1>@localhost” identified by ‘password‘;
flush privileges;
create database dataname2;
grant all privileges on dataname2.* to username2>@localhost” identified by ‘password‘;
flush privileges;