1. 问题描述:在canal演示ClientExample案例时,在java客户端没有监听到mysql数据库的数据变化,导致控制台一直输出empty count
2. 具体解决:
1).首先登录mysql:
mysql -uroot -p
2).mysql 查看用户:这里有个canal用户
mysql> SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
+---------------------------------------+
| query |
+---------------------------------------+
| User: 'canal'@'%'; |
| User: 'mysql.infoschema'@'localhost'; |
| User: 'mysql.session'@'localhost'; |
| User: 'mysql.sys'@'localhost'; |
| User: 'root'@'localhost'; |
+---------------------------------------+
5 rows in set (0.00 sec)
3).更新一下用户密码:
mysql> ALTER USER 'canal'@'%' IDENTIFIED WITH mysql_native_password BY 'canal';
Query OK, 0 rows affected (0.01 sec)
如果host 是 localhost,这里改为以下更新一下用户密码:
ALTER USER 'canal'@'localhost' IDENTIFIED WITH mysql_native_password BY 'canal';
4).最后刷新权限:
FLUSH PRIVILEGES;
3. 总结:因为不同的版本问题,导致创建用户的赋予权限,密码出现了不同,设置成'%'的时候,会导致 'localhost'无法登录。所以需要用命令单独修改密码。
标签:canal,count,ok,empty,User,mysql,localhost From: https://www.cnblogs.com/container-simple/p/18238893