Skip to content

Commit

Permalink
Set the version of mysql to install using an environment variable.
Browse files Browse the repository at this point in the history
Older versions of mysql are not available in newer versions of Ubuntu. Use an environment variable to easily switch the version of mysql to install for the version of Ubuntu being used.
  • Loading branch information
patrickcarlohickman committed Jan 25, 2023
1 parent 2c1528d commit ff0c156
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions setup/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ GIT_EMAIL_ADDRESS=
VHOST_DIRECTORY="/var/www/vhost"

# install-mysql.sh
MYSQL_VERSION="8.0"
MYSQL_ROOT_PASSWORD=
MYSQL_USER_NAME=
MYSQL_USER_PASSWORD=
Expand Down
10 changes: 7 additions & 3 deletions setup/installers/install-mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ ensure_not_installed "MySQL"
ensure_variable_set "WSL_USER"

readonly WSL_USER
readonly MYSQL_VERSION="${MYSQL_VERSION:-8.0}"
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 WSL_USER_DIRECTORY="$(wsl_user_directory "${WSL_USER}")"

ensure_package_available "${MYSQL_PACKAGE}"

# Set the root password for when mysql is installed
debconf-set-selections <<< "mysql-server-5.7 mysql-server/root_password password ${MYSQL_ROOT_PASSWORD}"
debconf-set-selections <<< "mysql-server-5.7 mysql-server/root_password_again password ${MYSQL_ROOT_PASSWORD}"
debconf-set-selections <<< "${MYSQL_PACKAGE} mysql-server/root_password password ${MYSQL_ROOT_PASSWORD}"
debconf-set-selections <<< "${MYSQL_PACKAGE} mysql-server/root_password_again password ${MYSQL_ROOT_PASSWORD}"

log_info "Installing MySQL. This may take a few minutes..."

# Install mysql
apt-get -yqq update
DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server-5.7
DEBIAN_FRONTEND=noninteractive apt-get -y install ${MYSQL_PACKAGE}

log_info "Setting up mysql user home directory."

Expand Down

0 comments on commit ff0c156

Please sign in to comment.