MySQL 权限相关

# ============================= mysql 权限相关 =====================================================
grant 权限1,权限2,...权限n on 数据库名称.表名称 to 用户名@用户地址 identified by '连接口令';
#--- 创建应用账号
grant all privileges on *.* to 'root'@'localhost' identified by 'yourknown' ;
#-- 创建只读账号
grant select on *.* to 'sn_query'@'%' identified by 'yourknown'; 
grant select on live_sn.* to 'live_sn_query'@'%' identified by 'yourknown' ;

#-- 给予帐号权限
GRANT ALL PRIVILEGES ON 'mq_message'.* TO 'wxh'@'localhost';

#-- 从账号
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'10.0.0.103' identified BY 'yourknown';

grant all privileges on *.* to 'root'@'%' identified by 'yourknown' with grant option;
grant all privileges on *.* to 'root'@'58.211.28.xx' identified by 'yourknown' with grant option;
grant all privileges on ru_sn.* to 'ru_sn'@'localhost' identified by 'yourknown' with grant option;

select host,user,passwd from mysql.user;
FLUSH PRIVILEGES;

#查看账号权限
show grants for 'app_name'@'%';

#剔除账号权限
revoke insert on sakila.* from 'z1'@'localhost';


UPDATE `user` SET `Host`='192.192.192.192' WHERE `User`='root' 
delete from mysql.user where user='systemuser' and host='localhost';
FLUSH PRIVILEGES; 

#删除账户及权限
drop user 用户名@'%'
drop user 用户名@localhost

猜你喜欢

转载自www.cnblogs.com/xiaomoonsea/p/10363001.html