2016年4月24日 星期日

MariaDB 帳號建立與安全性管理指令


【登入】

mysql -u 帳號 -p


【遠端登入】

mysql -h 遠端位置 -u 帳號 -p



【本機登入】

sudo mysql -u root



在mysql>下

【查帳號】

select user from user;

【查詢帳號權限】

show grants for 帳號;

show grants for 'root'@'localhost'


【建立帳號並本機登入】

create user 帳號 identified by '密碼'


【建立帳號並可遠端登入】

create user '[USER_NAME]'@'%' 帳號 identified by '密碼';

create user 'myuser'@'%' identified by 'password';


【啓用root本機登入權限】

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '<PW>';

FLUSH PRIVILEGES;


【給該帳號和root 一樣的權限】

grant all on *.* to 帳號



【給帳號某個db的權限】

grant all on [DB_NAME].* to [帳號]








熱門文章