目录
创建mysql 账号 赋予权限 只读权限,创建存储过程执行权限
创建mysql 账号 赋予权限 只读权限,创建存储过程执行权限
1、创建mysql 账号 赋予权限
create user 'myuser'@'%' identified by 'mypassword';
2、赋予权限,myuser账号,某个IP下的所有权限;
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' ;
3、赋予权限,root账号,所有IP下的所有权限;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypassword' ;
4、赋予权限 只读权限
GRANT SELECT ON *.* TO 'bigdata'@'%' IDENTIFIED BY "123456";
Query OK, 0 rows affected (0.00 sec)
5、赋予存储过程执行权限;
grant execute on xrdatest.* TO bpmtest@'%' ;
6、使授权生效:
mysql> FLUSH PRIVILEGES;
7、撤销已经赋予用户的权限:
revoke 跟 grant 的语法差不多,只需要把关键字 “to” 换成 “from” 即可:
mysql>grant all on *.* to dba@localhost;
mysql>revoke all on *.* from dba@localhost;
8、案例脚本
[root@hostmod ~]# mysql -uroot -pP@ssw0rd#200
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 101972
Server version: 5.7.24 MySQL Community Server (GPL)
Copyright