关于 MySQL Binlog 权限

Tony哥
2022-09-15 / 2 评论 / 794 阅读 / 正在检测是否收录...

MySQL Binlog 权限

  • Check binlog status

    show variables like 'log_bin'; 
    show variables like 'binlog_format'; 
    MySQL Binlog权限需要三个权限 SELECT, REPLICATION SLAVE, REPLICATION CLIENT
    GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%' IDENTIFIED BY 'canal'; 
    缺乏SELECT权限时,报错为
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
    Access denied for user 'canal'@'%' to database 'binlog' 
    缺乏REPLICATION SLAVE权限时,报错为
    java.io.IOException: 
    Error When doing Register slave:ErrorPacket [errorNumber=1045, fieldCount=-1, message=Access denied for user 'canal'@'%' 
    缺乏REPLICATION CLIENT权限时,报错为
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 
    Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation

Binlog为什么需要这些权限:

  • Select权限代表允许从表中查看数据
  • Replication client权限代表允许执行show master status,show slave status,show binary logs命令
  • Replication slave权限代表允许slave主机通过此用户连接master以便建立主从 复制关系
1

评论 (2)

取消
  1. 头像
    qqq
    Windows 10 · Google Chrome

    errorNumber=1045, fieldCount=-1
    这个就是因为密码不对。。。不是什么没权限

    回复
    1. 头像
      Tony哥2
      Windows 10 · Google Chrome
      @ qqq

      感谢你的纠正

      回复