问题描述:mysql在执行show master status指令时,报错"ERROR 1227 (42000)",如下所示:
数据库:mysql 8.0.27
系统:rhel 7.3
1、异常重现
[root@leo-mysql-master etc]# mysql -urepluser -h 192.168.133.111 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 12
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> show master status;
ERROR 1227 (42000): Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation
说明:如上所示,用户repluser无法查看状态.
2、解决方案
--以root用户登录,授予replication client权限给repluser用户.
[root@leo-mysql-master etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 13
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> grant replication client on *.* to repluser@'192.168.133.%';
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@leo-mysql-master etc]# mysql -urepluser -h 192.168.133.111 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 14
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> show master status;
+-------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------+----------+--------------+------------------+-------------------+
| master_bin.000001 | 957 | | | |
+-------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: SQL学习日记二、修改基本表三、索引的建立与删除四、数据操纵(insert,update,delete)五、单表查询(select)六、多表查询七、集合查询八、视图九、数据安全
目录 一、数据定义(create,alter,drop) 1.1数据类型 补充注释 1.2定义基本表(create,alter,drop) 1.3约束 1.3.1主键约束 1.3.2外码约束 编辑 补充CASCADE 关键字 1.3.3Check约束 1.3…