Skip to content

Cannot connect to cloud-sql-proxy with passwordless login #1584

@ptwales

Description

@ptwales

I'm running cloud-sql-proxy with --auto-iam-authn to connect to a google hosted sql database. I cannot connect to that database proxy with mycli>=1.43.0. Older versions of mycli work (latest 1.42.0), so does usql and the stock mariadb client.

Expected Behavior

While running

cloud-sql-proxy --auto-iam-authn <PROJECT>:<ZONE>:<DB> --port 3308

I should be able to immediately connect to that database without providing a password with

mycli -h 127.0.0.1 -P 3308 -u <USER> -D <DATABASE>

Actual Behavior

I get the output

# 2026-02-18 12:12:47,988 WARNING mycli.config config.py:23 -- Unable to parse line 10 of config file '/etc/my.cnf'.

# 2026-02-18 12:12:47,988 WARNING mycli.config config.py:23 -- Using successfully parsed config values.

# 2026-02-18 12:12:47,988 WARNING mycli.config config.py:23 -- Unable to parse line 52 of config file '/etc/my.cnf.d/server.cnf'.

# 2026-02-18 12:12:47,988 WARNING mycli.config config.py:23 -- Using successfully parsed config values.

Enter password for <USER>: <CR>
# 2026-02-18 12:12:49,080 ERROR mycli.main main.py:721 -- traceback: 'Traceback (most recent call last):\n  File "/usr/lib/python3.14/site-packages/mycli/main.py", line 718, in connect\n    _connect()\n    ~~~~~~~~^^\n  File "/usr/lib/python3.14/site-packages/mycli/main.py", line 682, in _connect\n    raise e1\n  File "/usr/lib/python3.14/site-packages/mycli/main.py", line 640, in _connect\n    self.sqlexecute = SQLExecute(\n                      ~~~~~~~~~~^\n        database,\n        ^^^^^^^^^\n    ...<14 lines>...\n        unbuffered,\n        ^^^^^^^^^^^\n    )\n    ^\n  File "/usr/lib/python3.14/site-packages/mycli/sqlexecute.py", line 189, in __init__\n    self.connect()\n    ~~~~~~~~~~~~^^\n  File "/usr/lib/python3.14/site-packages/mycli/sqlexecute.py", line 280, in connect\n    conn = pymysql.connect(\n        database=db,\n    ...<15 lines>...\n        cursorclass=pymysql.cursors.SSCursor if unbuffered else pymysql.cursors.Cursor,\n    )  # type: ignore[misc]\n  File "/usr/lib/python3.14/site-packages/pymysql/connections.py", line 365, in __init__\n    self.connect()\n    ~~~~~~~~~~~~^^\n  File "/usr/lib/python3.14/site-packages/pymysql/connections.py", line 681, in connect\n    self._request_authentication()\n    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^\n  File "/usr/lib/python3.14/site-packages/pymysql/connections.py", line 958, in _request_authentication\n    auth_packet = self._read_packet()\n  File "/usr/lib/python3.14/site-packages/pymysql/connections.py", line 751, in _read_packet\n    packet_header = self._read_bytes(4)\n  File "/usr/lib/python3.14/site-packages/pymysql/connections.py", line 805, in _read_bytes\n    raise err.OperationalError(\n        CR.CR_SERVER_LOST, "Lost connection to MySQL server during query"\n    )\npymysql.err.OperationalError: (2013, \'Lost connection to MySQL server during query\')\n'

(2013, 'Lost connection to MySQL server during query')

The cloud-sql-proxy process only logs

Accepted connection from 127.0.0.1:34430
instance closed the connection

The my.cnf warnings I believe are unrelated but I'm including them in case I'm wrong.

Steps to Reproduce

You'll need a mysql database from hosted by google. I can't provide instructions for setting that up because I didn't set this one up. You'll also need to install gcloud and connect to the project with the database. Once you have all that set up its just the two commands I gave in Expected Behavior.

System

  • mycli version: Anything above 1.43.0
  • OS/version: Arch linux 6.12.68-1-lts
  • cloud-sql-proxy version: 2.21.0+linux.amd64

Discussion

I'm currently circumventing by manually downgrading the PKGBUILD to 1.42.0. I get some warnings about "No user completions due to... (permissions error)" but I can live with that.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions