From 3586c28c5824ce3f11930784f163ece0d4a37d10 Mon Sep 17 00:00:00 2001 From: Alexandros Evangelou Date: Mon, 31 Aug 2026 14:48:04 +0300 Subject: [PATCH 1/2] fix: repair ethopy-setup-djdocker for new installs A fresh install could not connect to the database it had just created. - Bump the generated docker-compose.yaml from datajoint/mysql:5.7 to datajoint/mysql:8. MySQL 5.7 offers only a SHA-1 cipher suite, which current Python refuses to negotiate, so any environment built after PyMySQL 1.2.0 (May 2026) failed with SSLV3_ALERT_HANDSHAKE_FAILURE. On mysql:8 the connection works and is genuinely encrypted. Pinning pymysql<1.2 was rejected: it hides the problem instead of fixing it. - Warn when a data_* directory already exits MYSQL_ROOT_PASSWORD only when initialising an empty data directory, so a leftover one silently kept its old pasin a bare "Access denied for user 'root'". - Use sys.executable rather than a bare `python` when creating schemas. --- src/ethopy/setup_db.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/ethopy/setup_db.py b/src/ethopy/setup_db.py index df4afa5..e569ba4 100644 --- a/src/ethopy/setup_db.py +++ b/src/ethopy/setup_db.py @@ -7,6 +7,7 @@ import os import socket import subprocess +import sys from pathlib import Path from time import sleep from typing import Optional, Tuple @@ -197,16 +198,27 @@ def setup_dj_docker(mysql_path: Optional[str], container_name: str) -> None: mysql_dir.mkdir(parents=True, exist_ok=True) os.chdir(str(mysql_dir)) + # MySQL only honours MYSQL_ROOT_PASSWORD when it initialises an empty + # data directory, so a leftover one silently keeps its old credentials. + data_dir = mysql_dir / f"data_{container_name}" + if data_dir.exists(): + click.echo( + f"WARNING: a MySQL data directory already exists at {data_dir}.\n" + "MySQL will reuse it and IGNORE the password entered below - the " + "root password stored in that directory stays in force.\n" + "Enter that existing password, or press Ctrl-C and move the " + "directory aside to start from a clean database." + ) + # Get password securely using Click's password prompt mysql_password = click.prompt( "Enter the MySQL root password", hide_input=True, confirmation_prompt=True ) docker_content = ( - f"version: '2.4'\n" f"services:\n" f" {container_name}:\n" - f" image: datajoint/mysql:5.7\n" + f" image: datajoint/mysql:8\n" f" environment:\n" f" - MYSQL_ROOT_PASSWORD={mysql_password}\n" f" ports:\n" @@ -290,7 +302,10 @@ def createschema() -> None: try: # Capture both stdout and stderr _ = subprocess.run( - ["python", "-c", cmd], check=True, capture_output=True, text=True + [sys.executable, "-c", cmd], + check=True, + capture_output=True, + text=True, ) click.echo(f"Successfully created tables for: {schema_name}") From c10ecc0915e7555d0b8781db09abc5e868836de4 Mon Sep 17 00:00:00 2001 From: Alexandros Evangelou Date: Mon, 31 Aug 2026 14:48:29 +0300 Subject: [PATCH 2/2] udpate docs to show mysql:8 instead of mysql:5.7 --- docs/database_setup.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/database_setup.md b/docs/database_setup.md index 13d55a7..54e02fd 100644 --- a/docs/database_setup.md +++ b/docs/database_setup.md @@ -28,7 +28,7 @@ This command will: 5. Start the container The Docker container uses: -- Image: `datajoint/mysql:5.7` (https://github.com/datajoint/mysql-docker) +- Image: `datajoint/mysql:8` (https://github.com/datajoint/mysql-docker) - Port: 3306 (standard MySQL port) - Volume: `./data_ethopy_sql_db:/var/lib/mysql` for persistent data storage @@ -38,10 +38,9 @@ If you prefer to set up the container manually: 1. Create a `docker-compose.yaml` file: ```yaml -version: '2.4' services: ethopy_sql_db: - image: datajoint/mysql:5.7 + image: datajoint/mysql:8 environment: - MYSQL_ROOT_PASSWORD=your_password ports: