Mysql 快速創建賬號並授權只讀權限


創建賬號

本地訪問:

create user username@localhost identified by 'password';

外網訪問:

create user 'username'@'%' identified by 'password';
flush privileges;
賬號授權database_name數據庫所有權限
grant all privileges on `database_name`.* to 'username'@'%' identified by 'password';
flush privileges;
只讀權限
grant select on database1.* to 'username'@'%' identified by 'password';
grant select on database2.* to 'username'@'%' identified by 'password';
flush privileges;
-- select 查詢權限,all privileges 所有權限或指定select,delete,update,create,drop權限
-- database1 數據庫
-- username 用戶賬號
-- password 密碼
-- % 所有電腦可訪問


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM