grant

mysql用户与权限操作

十年热恋 提交于 2019-12-16 11:41:56
本文所有操作均在mysql8.1下验证,mysql5.x部分语句不适用。 1、创建用户 create user 'test'@'%' identified by '123456'; # 创建用户test,密码123456,%表示允许在所有主机登陆 用户表为mysql库小的user表,Host+User为联合主键 。 User+Host唯一确认一个用户,本文中的用户均已 'User'@'Host' 格式表示。 2、修改密码 alter user 'test'@'%' identified by '654321'; # 修改密码为654321 3、删除用户 drop user 'test'@'%'; 4、分配权限 grant语句会做并集处理,而且只能分配当前操作用户所拥有的权限。 1)对 test'@'%' 用户分配所有库的全部表的全部操作权限,*.*:第一个*表示全部库,第二个*表示库下的所有表 grant all on *.* to 'test'@'%'; grant all on *.* to 'test'@'%' with grant option; // with grant option,权限可继续分配 2)分配具体库的全部表权限: grant all on db_test.* to 'test'@'%'; 3)只分配具体表的权限: grant all on db_test

Mysql-mysql8创建用户用户并授权-远程访问

吃可爱长大的小学妹 提交于 2019-12-15 02:45:54
1.创建用户 若想要密码简单点的话,需要更改密码策略 查看密码策略 SHOW VARIABLES LIKE 'validate_password%' ; 设置密码长度和密码政策 set global validate_password . length = 4 ; set global validate_password . policy = 0 ; flush privileges ; 创建一个pos用户 create user pos identified by 'pospos' ; 密码是pospos 查看是否在user表中 2.授权 将pos数据库赋予pos用户全部权限 grant all privileges on pos . * to 'pos' @'%' with grant option ; mysql5的语法为 grant all privileges on pos . * to pos@' % ' identified by ' pospos' ; //这样在mysql8中会报语法错误 3.远程连接 GRANT ALL ON *.* TO 'root'@'%'; ALTER USER 'pos'@'%' IDENTIFIED WITH mysql_native_password BY 'pospos'; flush privileges; GRANT ALL

Granting SELECT on all tables to a user in Firebird 2.1

折月煮酒 提交于 2019-12-14 03:08:42
问题 I've added a user to a Firebird 2.1 instance using gsec , but now I wanted to grant SELECT on all tables to this new user. I could find how to grant this permission on specific tables, but not to them all: GRANT SELECT ON TABLE table TO USER user; If I try to use the new user I get the following error on isql: no permission for read/select access to TABLE table Is there a way to do that on Firebird 2.1? 回答1: Something like this: EXECUTE BLOCK AS DECLARE VARIABLE tablename VARCHAR(32); BEGIN

How to create role with MySQL database

徘徊边缘 提交于 2019-12-13 13:48:23
问题 Is there a way to use CREATE ROLE with MySQL? It's possible to create roles with PostgreSQL but when I try with MySQL it returns this error message: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'role famille' at line 1 回答1: MySQL 5 has no ROLES (https://dev.mysql.com/doc/refman/5.7/en/faqs-security.html#faq-mysql-have-builtin-rbac). If you would be looking for RDBMS that is compatible with MySQL

Command denied for table 'session_variables'

夙愿已清 提交于 2019-12-13 02:58:57
问题 After updating mysql version 5.7.8-rc-log, I granted privileges like this: GRANT select ON test_db.* TO 'test'@'host'; and getting following error: SELECT command denied to user 'test'@'host' for table 'session_variables' but when I grant privileges like this: GRANT select ON *.* TO 'test'@'host'; it works. Can anybody help? 回答1: Here are the article1, article2, article3 related to this issue. As per these articles, Workaround is setting show_compatibility_56 = on in /etc/my.cnf and restart

mysql8创建只读帐号

不想你离开。 提交于 2019-12-13 01:18:49
网上有的直接创建并赋权,像酱紫的: grant all privileges *.* to '要创建的用户'@'localhost' identified by '自定义密码'; mysql8试了不行,要先创建用户再进行赋权,不能同时进行 创建用户 create user 'test1'@'localhost' identified by '密码'; flush privileges;刷新权限 其中localhost指本地才可连接 可以将其换成%指任意ip都能连接 也可以指定ip连接 修改密码 alter user 'test1'@'localhost' identified by '新密码'; flush privileges; 授权 grant all privileges on *.* to 'test1'@'localhost' with grant option; with gran option表示该用户可给其它用户赋予权限,但不可能超过该用户已有的权限 比如a用户有select,insert权限,也可给其它用户赋权,但它不可能给其它用户赋delete权限,除了select,insert以外的都不能 这句话可加可不加,视情况而定。 all privileges 可换成select,update,insert,delete,drop,create等操作 如:grant

MYSQL创建用户

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 15:16:57
MYSQL创建用户 如何在MySQL中创建用户和授予权限 一. 创建用户: 命令:CREATE USER ‘username’@‘host’ IDENTIFIED BY ‘password’; 例子: CREATE USER ‘dog’@‘localhost’ IDENTIFIED BY ‘123456’; CREATE USER 'dog2'@'localhost' IDENTIFIED BY ''; PS:username - 你将创建的用户名, host - 指定该用户在哪个主机上可以登陆,此处的"localhost",是指该用户只能在本地登录,不能在另外一台机器上远程登录,如果想远程登录的话,将"localhost"改为"%",表示在任何一台电脑上都可以登录;也可以指定某台机器可以远程登录; password - 该用户的登陆密码,密码可以为空,如果为空则该用户可以不需要密码登陆服务器。 二.授权: 命令:GRANT privileges ON databasename.tablename TO ‘username’@‘host’ PS: privileges - 用户的操作权限,如SELECT , INSERT , UPDATE 等(详细列表见该文最后面).如果要授予所的权限则使用ALL.;databasename - 数据库名,tablename-表名

Can't access to some database being root, after just creating that database

不羁岁月 提交于 2019-12-12 14:56:14
问题 as root@localhost mysql> CREATE USER 'aaa'@'%'; Query OK, 0 rows affected (0.00 sec) mysql> GRANT USAGE ON * . * TO 'aaa'@'%' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; Query OK, 0 rows affected (0.00 sec) mysql> CREATE DATABASE IF NOT EXISTS `aaa` ; Query OK, 1 row affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL PRIVILEGES ON `aaa` . * TO 'aaa'@'%'; ERROR 1044 (42000): Access denied

SQL5193N The current session user does not have usage privilege on any enabled workloads

南笙酒味 提交于 2019-12-12 06:30:42
问题 I'm getting the error while querying DB2 database 'SQL5193N The current session user does not have usage privilege on any enabled workloads' How should I check if a user has usage permission on workloads? 回答1: To granting the USAGE privilege on a workload. You can use; http://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.admin.wlm.doc/doc/t0051489.html To check whether the user has DBADM authority: db2 "SELECT DISTINCT GRANTEETYPE, GRANTEE, DBADMAUTH from SYSCAT.DBAUTH" To

个人的一些MySql管理经验

和自甴很熟 提交于 2019-12-11 13:56:03
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>      当前一般用户的开发环境多是Windows或Linux,用户可以到http://www.mysql.com下载相关版本进行安装,在 windows中MySql以服务形式存在,在使用前应确保此服务已经启动,未启动可用net start mysql命令启动。   MySQL数据库是中小型网站后台数据库的首选,因为它对非商业应用是免费的.网站开发者可以搭建一个"Linux+Apache+PHP+MySql" 平台,这是一个最省钱的高效平台.在使用MySql进行开发时,MySql自带的文档对于新手来说是份很好的参考资料.本文是我在使用MySql中的小小心得。   当前一般用户的开发环境多是Windows或Linux,用户可以到http://www.mysql.com下载相关版本进行安装,在 windows中MySql以服务形式存在,在使用前应确保此服务已经启动,未启动可用net start mysql命令启动。而Linux中启动时可用“/etc/rc.d/init.d/mysqld start"命令,注意启动者应具有管理员权限。   刚安装好的MySql包含一个含空密码的root帐户和一个匿名帐户,这是很大的安全隐患,对于一些重要的应用我们应将安全性尽可能提高,在这里应把匿名帐户删除、 root帐户设置密码