MySQL数据库权限操作

发布时间:2020-07-20 14:32:32 作者:我要成神
来源:网络 阅读:475

操作对象:

线上和测试所有MySQL Plus数据库

创建用户:


create user 'testname'@'%' identified by '123456';

查看testname用户的权限


show grants for testname;

testname用户授权:


GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX,ALTER,SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON *.* TO 'testnam'@'%';

#创建用户并授权


GRANT ALL PRIVILEGES ON *.* TO 'testname'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;

testname用户原有权限:


SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX,ALTER,SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER

查看用户的授权权限:


select * from mysql.user where User='testname' and Host='%'\G;

修改用户的授权权限:


update mysql.user set Grant_priv='Y' where User='testname' and Host='%';

flush privileges;

回收权限:


CREATE,DROP,ALTER

revoke CREATE,DROP,ALTER on *.* from testname@'%';

线上授权testname1:


GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON *.* TO 'testname1'@'%';

mysqladmin -u testname1 -h2.1.1.1 password C123456 "c123456"

修改密码:


set password = password 'C123456';
推荐阅读:
  1. JQUERY实现左右权限的操作方法
  2. 操作MySQL数据库

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

数据库 mysql 权限操作

上一篇:调整spyder缩进和对齐线的方法

下一篇:如何使用JS 中 onchange 事件

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》