帶您深入了解MySQL權(quán)限管理
不同的權(quán)限在MySQL數(shù)據(jù)庫上能進行的操作是不同的,下面就為您介紹MySQL權(quán)限管理的一些知識,如果您對MySQL權(quán)限管理方面感興趣的話,不妨一看。
========對于ROOT用戶的密碼操作(更改用戶密碼)========
剛剛安裝完的MySQL,MySQL權(quán)限管理上只一有個root用戶,密碼為空,而且只能在本機登錄!
為root加上密碼xxx123:
./bin/mysqladmin -u root password xxx123
或?qū)懗?br />
./bin/mysqladmin -uroot password xxx123
加下密碼之后,在本進行進入mysql:
./bin/mysql -uroot -p
更改root的密碼由xxx123改為yy1234:
./bin/mysqladmin -uroot -pxxx123 password yy1234
=======grant 權(quán)限 on 數(shù)據(jù)庫對象 to 用戶==========
MySQL 賦予用戶權(quán)限命令的簡單格式可概括為:
grant 權(quán)限 on 數(shù)據(jù)庫對象 to 用戶
grant 權(quán)限 on 數(shù)據(jù)庫對象 to 用戶 identified by "密碼"
========用戶及權(quán)限管理:最常用操作實例========
(用戶名:dba1,密碼:dbapasswd,登錄IP:192.168.0.10)
//開放管理MySQL中所有數(shù)據(jù)庫的權(quán)限
grant all on *.* to dba1@'192.168.0.10'identified by "dbapasswd";
//開放管理MySQL中具體數(shù)據(jù)庫(testdb)的權(quán)限
grant all privileges on testdb to dba1@'192.168.0.10'identified by "dbapasswd";
或
grant all on testdb to dba1@'192.168.0.10'identified by "dbapasswd";
//開放管理MySQL中具體數(shù)據(jù)庫的表(testdb.table1)的權(quán)限
grant all on testdb.teable1 to dba1@'192.168.0.10'identified by "dbapasswd";
//開放管理MySQL中具體數(shù)據(jù)庫的表(testdb.table1)的部分列的權(quán)限
grant select(id, se, rank) on testdb.table1 to ba1@'192.168.0.10'identified by "dbapasswd";
//開放管理操作指令
grant select, insert, update, delete on testdb.* to dba1@'192.168.0.10'identified by "dbapasswd";
//回收權(quán)限
revoke all on *.* from dba1@localhost;
//查看 MySQL 用戶權(quán)限
show grants;
show grants for dba1@localhost;
以上就是MySQL權(quán)限管理的介紹。
【編輯推薦】