# 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
藍(lán)色斜體部分為對應(yīng)的用戶名和密碼,添加多個用戶及數(shù)據(jù)庫,只需要復(fù)制中間部分代碼并修改對應(yīng)的位置即可,如:
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;
以上內(nèi)容給大家分享了mysql通過文檔讀取并執(zhí)行命令之快速為mysql添加多用戶和數(shù)據(jù)庫技巧,希望大家喜歡,關(guān)于數(shù)據(jù)庫內(nèi)容請持續(xù)關(guān)注本站,本站每天都有新的內(nèi)容更新