创建一个具有超级用户权利的用户

1
GRANT
ALL
ON
*.*
TO
anyname@localhost IDENTIFIED
BY
"passwd"
WITH
GRANT
OPTION
;

数据库级权限用一个ON db_name.*子句而不是ON *.*进行授权:

1
GRANT
ALL
ON
xy_db_activity
TO
boris@localhost IDENTIFIED
BY
"boris"
;

如果你为一个数据库授权,如果需要在mysql.db表中创建一个条目。

1
GRANT
ALL
ON
xy_db_config
TO
kite@localhost IDENTIFIED
BY
"ruby"
;

当所有为数据库的授权用REVOKE删除时,这个条目被删除。

1
REVOKE
ALL
ON
xy_db_config
FROM
kite@localhost;

授权java用户192.168.1.99ip所有权限

1
2
3
4
5
mysql>
select
* from user;
mysql> GRANT ALL ON *.* TO java@
'192.168.1.99'
IDENTIFIED BY
"java"
WITH GRANT OPTION;
GRANT ALL ON *.* TO java@
'192.168.1.31'
IDENTIFIED BY
"java"
;
SHOW GRANTS;
FLUSH PRIVILEGES;

查看用户授权信息

1
SHOW GRANTS
FOR
java@
'192.168.1.32'
;

淘宝小店-运维学习参考资料