復制代碼 代碼如下:
# 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;
以上內容給大家分享了mysql通過文檔讀取並執行命令之快速為mysql添加多用戶和數據庫技巧,希望大家喜歡,關於數據庫內容請持續關注本站,本站每天都有新的內容更新