Skip to content

Commit

Permalink
Update the mysql installer to allow specifying the port to use in the…
Browse files Browse the repository at this point in the history
… .env file.
  • Loading branch information
patrickcarlohickman committed Feb 5, 2024
1 parent 47ca105 commit b6e5818
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 2 additions & 0 deletions setup/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ MYSQL_USER_PASSWORD=
# Optional - if specified, set the default_authentication_plugin server variable
# Can be one of (for 8.0): mysql_native_password, sha256_password, caching_sha2_password (default)
# MYSQL_AUTH_PLUGIN="mysql_native_password"
# Optional - Specify the port for the mysql server and clients to use (if not 3306).
# MYSQL_PORT="3306"

# install-ngrok.sh
NGROK_DIRECTORY="/opt/ngrok"
Expand Down
14 changes: 14 additions & 0 deletions setup/installers/install-mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ readonly MYSQL_PACKAGE="mysql-server-${MYSQL_VERSION}"
readonly MYSQL_ROOT_PASSWORD="${MYSQL_ROOT_PASSWORD:-root}"
readonly MYSQL_USER_NAME="${MYSQL_USER_NAME:-homestead}"
readonly MYSQL_USER_PASSWORD="${MYSQL_USER_PASSWORD:-secret}"
readonly MYSQL_PORT="${MYSQL_PORT:-3306}"
readonly WSL_USER_DIRECTORY="$(wsl_user_directory "${WSL_USER}")"

ensure_package_available "${MYSQL_PACKAGE}"
Expand Down Expand Up @@ -42,6 +43,19 @@ default_authentication_plugin=${MYSQL_AUTH_PLUGIN}
EOF
fi

# Set the port to use if different than the default.
if [[ "${MYSQL_PORT}" -ne "3306" ]]; then
log_info "Setting up mysql port config file."

cat << EOF > "/etc/mysql/mysql.conf.d/z_port.cnf"
[mysqld]
port=${MYSQL_PORT}
[client]
port=${MYSQL_PORT}
EOF
fi

log_info "Starting MySQL server."

# Make sure it is started
Expand Down
13 changes: 0 additions & 13 deletions todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,3 @@ sudo cp cacert.pem /etc/ssl/certs/
maybe create a helper script to periodically keep this up to date
=====================================
=====================================

=====================================
mysql
=====================================
# allow installer to specify port
cat /etc/mysql/mysql.conf.d/z_port.cnf
[mysqld]
port=3307

[client]
port=3307
=====================================
=====================================

0 comments on commit b6e5818

Please sign in to comment.