Skip to content

Commit a68d6ab

Browse files
chriscrosstalkclaude
authored andcommitted
fix(install): prevent MySQL credential mismatch on reinstall
When the install script runs a second time (e.g., after a failed first attempt), it generates new random database passwords and writes them to compose.yml. However, MySQL only initializes credentials on first startup when its data directory is empty. If /opt/project-nomad/mysql/ persists from the previous attempt, MySQL skips initialization and keeps the old passwords, causing "Access denied" errors for nomad_admin. Fix: remove the MySQL data directory before generating new credentials so MySQL reinitializes with the correct passwords. Closes #404 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 09c12e7 commit a68d6ab

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

install/install_nomad.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,15 @@ download_management_compose_file() {
403403
local db_root_password=$(generateRandomPass)
404404
local db_user_password=$(generateRandomPass)
405405

406+
# If MySQL data directory exists from a previous install attempt, remove it.
407+
# MySQL only initializes credentials on first startup when the data dir is empty.
408+
# If stale data exists, MySQL ignores the new passwords above and uses the old ones,
409+
# causing "Access denied" errors when the admin container tries to connect.
410+
if [[ -d "${NOMAD_DIR}/mysql" ]]; then
411+
echo -e "${YELLOW}#${RESET} Removing existing MySQL data directory to ensure credentials match...\\n"
412+
sudo rm -rf "${NOMAD_DIR}/mysql"
413+
fi
414+
406415
# Inject dynamic env values into the compose file
407416
echo -e "${YELLOW}#${RESET} Configuring docker-compose file env variables...\\n"
408417
sed -i "s|URL=replaceme|URL=http://${local_ip_address}:8080|g" "$compose_file_path"

0 commit comments

Comments
 (0)