Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Upcoming (TBD)
Features
---------
* Add a `--batch` option as an alternative to STDIN.
* Deprecate `$MYSQL_UNIX_PORT` environment variable in favor of `$MYSQL_UNIX_SOCKET`.


Bug Fixes
Expand Down
15 changes: 14 additions & 1 deletion mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ def get_last_query(self) -> str | None:
@click.option("-h", "--host", envvar="MYSQL_HOST", help="Host address of the database.")
@click.option("-P", "--port", envvar="MYSQL_TCP_PORT", type=int, help="Port number to use for connection. Honors $MYSQL_TCP_PORT.")
@click.option("-u", "--user", help="User name to connect to the database.")
@click.option("-S", "--socket", envvar="MYSQL_UNIX_PORT", help="The socket file to use for connection.")
@click.option("-S", "--socket", envvar="MYSQL_UNIX_SOCKET", help="The socket file to use for connection.")
@click.option(
"-p",
"--pass",
Expand Down Expand Up @@ -2188,6 +2188,7 @@ def get_password_from_file(password_file: str | None) -> str | None:
else:
click.secho(alias)
sys.exit(0)

if list_ssh_config:
ssh_config = read_ssh_config(ssh_config_path)
try:
Expand All @@ -2202,6 +2203,18 @@ def get_password_from_file(password_file: str | None) -> str | None:
else:
click.secho(host_entry)
sys.exit(0)

if 'MYSQL_UNIX_PORT' in os.environ:
# deprecated 2026-03
click.secho(
"The MYSQL_UNIX_PORT environment variable is deprecated in favor of MYSQL_UNIX_SOCKET. "
"MYSQL_UNIX_PORT will be removed in a future release.",
err=True,
fg="red",
)
if not socket:
socket = os.environ['MYSQL_UNIX_PORT']

# Choose which ever one has a valid value.
database = dbname or database

Expand Down
Loading