首页 > 数据库 >关于 mysql5.7 中 创建一个用户 并为其 grant 权限 操作失败的问题

关于 mysql5.7 中 创建一个用户 并为其 grant 权限 操作失败的问题

时间:2022-08-17 15:15:22浏览次数:62  
标签:canal password grant -- mysql5.7 set user validate 权限

SQL:

-- 创建授权 canal 账号  具有 slave 权限
-- 查看密码策略状态
select plugin_name, plugin_status from information_schema.plugins where plugin_name like 'validate%';
-- 查看密码策略
show variables like 'validate_password%';
-- 修改密码策略
set global validate_password_mixed_case_count=0;
set global validate_password_number_count=0;
set global validate_password_special_char_count=0;
set global validate_password_length=4;
set global validate_password_policy=low;
-- 创建用户
create user canal identified by 'canal';  
-- 赋予权限
grant select, replication slave, replication client on *.*  to 'canal'@'%' identified by 'canal';
-- 此时报错:Access denied for user 'root'@'%' (using password: YES)
-- 其他尝试
grant all privileges on *.*  to 'canal'@'%' identified by 'canal';
grant all privileges on *.*  to 'canal'@'%' ;
-- 查询 root 权限
show grants for  'root'@'%' ;
-- all privileges 但是仍然失败,bsbdqj,查询 mysql.user 表
select user,host,Grant_priv from mysql.user;
-- 发现非本地 root 无权授权 定位问题
-- 本地 root 登录失败,重置密码
update mysql.user set authentication_string = password('root') where user='root' and host = 'localhost';
-- 仍然登录失败,刷新权限
flush privileges;
-- 登录成功
select * from mysql.user where user='root' and host='localhost' \G;
-- hys!
show grants for  'canal'@'%';
+-----------------------------------+
| Grants for canal@%                |
+-----------------------------------+
| GRANT USAGE ON *.* TO 'canal'@'%' |
+-----------------------------------+

grant all privileges on *.*  to 'canal'@'%' with grant option;
select * from mysql.user where user='canal' \G;
revoke super on *.* from canal@'%'; 
select * from mysql.user where user='canal' \G;
revoke all on *.* from 'canal'@'%' ;
select * from mysql.user where user='canal' \G;
revoke grant option on *.* from canal@'%'; 
drop user 'canal'@'%';
create user canal identified by 'canal';  
grant all privileges on *.*  to 'canal'@'%';
select * from mysql.user where user='canal' \G;
revoke all on *.* from 'canal'@'%' ;
-- revoke all privileges on *.* from 'canal'@'%' ;

-- drop 会权限表的内容,而 delete 后需要执行 flush privileges,否则下次 create 创建用户会报错。
delete from user where user='canal' and host='localhost';
flush privileges;
grant select, replication slave, replication client on *.*  to 'canal'@'%' identified by 'canal';
show warnings;
select authentication_string from mysql.user where user='canal';
+-------------------------------------------+
| authentication_string                     |
+-------------------------------------------+
| *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-------------------------------------------+
update mysql.user set authentication_string = password('canal')  where user='canal';
+---------+------+-------------------------------------------------------------------+
| Level   | Code | Message                                                           |
+---------+------+-------------------------------------------------------------------+
| Warning | 1681 | 'PASSWORD' is deprecated and will be removed in a future release. |
+---------+------+-------------------------------------------------------------------+
alter user canal@'%' identified by 'canal'; 
set global validate_password_mixed_case_count=1;
set global validate_password_number_count=1;
set global validate_password_special_char_count=1;
set global validate_password_length=8;
set global validate_password_policy=medium

 

标签:canal,password,grant,--,mysql5.7,set,user,validate,权限
From: https://www.cnblogs.com/chang09/p/16595255.html

相关文章

  • Linux—权限管理
    Linux权限管理1、权限简介Linux权限是操作系统用来限制对资源访问的机制,权限一般分为读、写、执行。系统中每个文件都拥有特定的权限:属主、属组以及其他人,通过这样的机......
  • vagrant在配置文件里面配置多个虚拟机
    vagrant通过配置文件Vagrantfile可以一次性配置多个虚拟机,通过定义 config.vm.define的方式Vagrant.configure("2")do|config|config.vm.define"web"do|web|......
  • 链接redis无权限问题
    docker启动redis,redis.conf中设置了"requirepass123456",但是不想改动配置。因此访问docker:dockerexec-itredisXXXX/bin/sh在/usr/local/bin下找到redis-cli命令,./r......
  • 宝塔面板无法修改文件权限为777如何解决?
    使用宝塔面板修改文件权限十分方便,但有时候无法修改,需要如何解决这个问题呢?步骤如下:方法一:使用Root账户及密码,强制更改权限1.使用root及其密码,SSH登录后,进入所需的文件夹......
  • SpringSecurity+Token实现权限校验
    1.SpringSecurity简介SpringSecurity是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架。它提供了一组可以在Spring应用上下文中配置的......
  • Mysql如何新建一个用户并赋予视图权限
    --新建用户CREATEUSER'viewUser'@'%'IDENTIFIEDBY'password'; -- 赋予视图权限GRANTSELECT,SHOWVIEWON`views`TO'viewUser'@'%' -- 并把视图内容......
  • mongo数据库-mongo角色权限
    Built-InRoles(内置角色):1.数据库用户角色:read、readWrite;2.数据库管理角色:dbAdmin、dbOwner、userAdmin;3.集群管理角色:clusterAdmin、clusterManager、clu......
  • android 文件访问权限处理
    对于/storage/emulated/0没没有权限访问的问题进行如下解决:1、加入文件读写、和存储管理权限READ_EXTERNAL_STORAGE MANAGE_EXTERNAL_STORAGE requestLegacyExternal......
  • django restframework 后端接口权限
    REST_FRAMEWORK={'EXCEPTION_HANDLER':'djangoProject.utils.exception.custom_exception_handler',#在不需要权限就能访问的视图设置permissions_classes......
  • VS2010 + Mysql5.7 使用ADO.Net Entity Framework
        系统很LOW,不想花太多时间来升级,可想做点什么,总是这也不行那也不行,更种安装要不就是vs版本太低,要不不支持低版本的mysql,调试起来很费时。用老版办法写代码又太费......