Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@924060929
Copy link
Contributor

@924060929 924060929 commented Oct 10, 2025

Support auto reconnect mysql server when mysql server restart

the mysql server restart, and mycli will throw exception: (0, '') forever

MySQL root@127.0.0.1:test> select 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set
Time: 0.019s
MySQL root@127.0.0.1:test> select 1; -- the mysql server stopped
Reconnecting...
(2003, "Can't connect to MySQL server on '127.0.0.1' ([Errno 61] Connection refused)")
MySQL root@127.0.0.1:test> select 1; -- the mysql server started, but throw exception: (0, '')
(0, '')

after this pr, the connection can reconnect:

MySQL root@127.0.0.1:test> select 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set
Time: 0.012s
MySQL root@127.0.0.1:test> select 1; -- the mysql server stopped
Reconnecting...
(2003, "Can't connect to MySQL server on '127.0.0.1' ([Errno 61] Connection refused)")
MySQL root@127.0.0.1:test> select 1; -- the mysql server started and can reconnect
Reconnecting...
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set
Time: 0.006s

Checklist

  • I've added this contribution to the changelog.md.
  • I've added my name to the AUTHORS file (or it's already there).
  • I ran uv run ruff check && uv run ruff format to lint and format the code.

@rolandwalker
Copy link
Contributor

Awesome! Can you update AUTHORS and changelog.md?

@924060929
Copy link
Contributor Author

Awesome! Can you update AUTHORS and changelog.md?

done, @rolandwalker can you review again?

@rolandwalker rolandwalker merged commit 4473e84 into dbcli:main Oct 14, 2025
8 checks passed
@rolandwalker
Copy link
Contributor

Thank you!

@924060929 924060929 deleted the reconnect-server branch October 23, 2025 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants