hcymysql / reverse_sql

Binlog数据恢复,生成反向SQL语句
66 stars 28 forks source link

pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '172.16.1.234' ([Errno 111] Connection refused)") #5

Open shukuinfo opened 9 months ago

shukuinfo commented 9 months ago

你好,一直提示无法连接数据库,但数据库是可以正常连接的,是什么原因呢 [root@node234 reverse_sql-reverse_sql_progress]# ./reverse_sql.py -ot test -op delete -H 172.16.1.234 -P 3336 -u root -p Rscpass123. -d test --binlog-file mysql-bin.000062 --start-time "2024-01-25 14:44:46" --end-time "2024-01-25 14:45:06" Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 916, in connect **kwargs) File "/usr/lib64/python3.6/socket.py", line 724, in create_connection raise err File "/usr/lib64/python3.6/socket.py", line 713, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./reverse_sql.py", line 368, in mysql_charset=args.mysql_charset File "./reverse_sql.py", line 40, in check_binlog_settings conn = pymysql.connect(*source_mysql_settings) File "/usr/local/lib/python3.6/site-packages/pymysql/init.py", line 90, in Connect return Connection(args, **kwargs) File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 706, in init self.connect() File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 963, in connect raise exc pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '172.16.1.234' ([Errno 111] Connection refused)")

shukuinfo commented 9 months ago

[root@node234 reverse_sql-reverse_sql_progress]# pip list Package Version


mysql-replication 0.13 pip 21.3.1 PyMySQL 0.7.11 pytz 2023.3.post1 setuptools 39.2.0 wheel 0.29.0

shukuinfo commented 9 months ago

[root@node234 reverse_sql-reverse_sql_progress]# python --version Python 3.6.2 [root@node234 reverse_sql-reverse_sql_progress]#

hcymysql commented 9 months ago

检查一下root账号,默认是不能远程连接的。创建一个新的账号admin@'%'(具备远程连接)