Skip to content

Commit 52ec2f9

Browse files
committed
remove support for deprecated $MYSQL_UNIX_PORT
environment variable, in favor of $MYSQL_UNIX_SOCKET. This has only been deprecated since March 2026, but it was also never documented.
1 parent a2ffb63 commit 52ec2f9

3 files changed

Lines changed: 28 additions & 38 deletions

File tree

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Upcoming (TBD)
2+
==============
3+
4+
Breaking Changes
5+
--------
6+
* Remove support for deprecated environment variable `$MYSQL_UNIX_PORT`.
7+
8+
19
1.75.0 (2026/06/20)
210
==============
311

mycli/cli_runner.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,6 @@ def run_from_cli_args(cli_args: 'CliArgs', client_factory: ClientFactory) -> Non
9797
if cli_args.list_ssh_config:
9898
sys.exit(main_list_ssh_config(mycli, cli_args))
9999

100-
if 'MYSQL_UNIX_PORT' in os.environ:
101-
# deprecated 2026-03
102-
click.secho(
103-
"The MYSQL_UNIX_PORT environment variable is deprecated in favor of MYSQL_UNIX_SOCKET. "
104-
"MYSQL_UNIX_PORT will be removed in a future release.",
105-
err=True,
106-
fg="red",
107-
)
108-
if not cli_args.socket:
109-
cli_args.socket = os.environ['MYSQL_UNIX_PORT']
110-
111100
if 'DSN' in os.environ:
112101
# deprecated 2026-03
113102
click.secho(

test/pytests/test_cli_runner.py

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -118,33 +118,6 @@ def test_run_from_cli_args_rejects_conflicting_format_flags(
118118
assert secho_calls == [(message, {'err': True, 'fg': 'red'})]
119119

120120

121-
def test_run_from_cli_args_uses_deprecated_mysql_unix_port_and_database_alias(
122-
monkeypatch: pytest.MonkeyPatch,
123-
) -> None:
124-
cli_args = make_cli_args()
125-
cli_args.database = 'prod'
126-
client = DummyMyCli(
127-
config={
128-
**default_config(),
129-
'alias_dsn': {'prod': 'mysql://dsn_user:dsn_pass@dsn_host:3307/dsn_db'},
130-
}
131-
)
132-
secho_calls: list[str] = []
133-
monkeypatch.setenv('MYSQL_UNIX_PORT', '/tmp/mysql.sock')
134-
monkeypatch.setattr(cli_runner.click, 'secho', lambda text, **_kwargs: secho_calls.append(text))
135-
136-
run_with_client(monkeypatch, cli_args, client)
137-
138-
assert client.dsn_alias == 'prod'
139-
assert client.connect_calls[-1]['database'] == 'dsn_db'
140-
assert client.connect_calls[-1]['user'] == 'dsn_user'
141-
assert client.connect_calls[-1]['passwd'] == 'dsn_pass'
142-
assert client.connect_calls[-1]['host'] == 'dsn_host'
143-
assert client.connect_calls[-1]['port'] == 3307
144-
assert client.connect_calls[-1]['socket'] == '/tmp/mysql.sock'
145-
assert any('MYSQL_UNIX_PORT environment variable is deprecated' in call for call in secho_calls)
146-
147-
148121
def test_run_from_cli_args_reports_missing_dsn(monkeypatch: pytest.MonkeyPatch) -> None:
149122
cli_args = make_cli_args()
150123
cli_args.dsn = 'missing'
@@ -165,6 +138,26 @@ def test_run_from_cli_args_reports_missing_dsn(monkeypatch: pytest.MonkeyPatch)
165138
]
166139

167140

141+
def test_run_from_cli_args_treats_database_as_dsn_alias(monkeypatch: pytest.MonkeyPatch) -> None:
142+
cli_args = make_cli_args()
143+
cli_args.database = 'prod'
144+
client = DummyMyCli(
145+
config={
146+
**default_config(),
147+
'alias_dsn': {'prod': 'mysql://u:p@h/db'},
148+
}
149+
)
150+
151+
run_with_client(monkeypatch, cli_args, client)
152+
153+
assert client.dsn_alias == 'prod'
154+
connect_call = client.connect_calls[-1]
155+
assert connect_call['user'] == 'u'
156+
assert connect_call['passwd'] == 'p'
157+
assert connect_call['host'] == 'h'
158+
assert connect_call['database'] == 'db'
159+
160+
168161
def test_run_from_cli_args_maps_dsn_ssl_parameters(monkeypatch: pytest.MonkeyPatch) -> None:
169162
cli_args = make_cli_args()
170163
cli_args.dsn = (

0 commit comments

Comments
 (0)