Created
December 2, 2019 23:25
-
-
Save dhnaranjo/eba234d1675ff878830f73ad9e1f3fba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install a custom MySQL 8.0 version - https://www.mysql.com | |
# | |
# To run this script on Codeship, add the following | |
# command to your project's setup commands: | |
# \curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/packages/mysql-8.0.sh | bash -s | |
# | |
# Add the following environment variables to your project configuration | |
# (otherwise the defaults below will be used). | |
# * MYSQL_VERSION | |
# * MYSQL_PORT | |
# | |
MYSQL_VERSION=${MYSQL_VERSION:="8.0.17"} | |
MYSQL_PORT=${MYSQL_PORT:="3308"} | |
set -e | |
MYSQL_DIR=${MYSQL_DIR:=$HOME/mysql-$MYSQL_VERSION} | |
DOWNLOAD_FILE_EXTENSION="tar.gz" | |
if [ "${MYSQL_VERSION:4}" -ge 12 ]; then | |
DOWNLOAD_FILE_EXTENSION="tar.xz" | |
fi | |
CACHED_DOWNLOAD="${HOME}/cache/mysql-${MYSQL_VERSION}-linux-glibc2.12-x86_64.${DOWNLOAD_FILE_EXTENSION}" | |
mkdir -p "${MYSQL_DIR}" | |
wget --verbose --continue --output-document "${CACHED_DOWNLOAD}" "https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-${MYSQL_VERSION}-linux-glibc2.12-x86_64.${DOWNLOAD_FILE_EXTENSION}" | |
tar -xaf "${CACHED_DOWNLOAD}" --strip-components=1 --directory "${MYSQL_DIR}" | |
mkdir -p "${MYSQL_DIR}/data" | |
mkdir -p "${MYSQL_DIR}/socket" | |
mkdir -p "${MYSQL_DIR}/log" | |
echo "# | |
# The MySQL 8.0 database server configuration file. | |
# | |
[client] | |
port = ${MYSQL_PORT} | |
socket = ${MYSQL_DIR}/socket/mysqld.sock | |
# This was formally known as [safe_mysqld]. Both versions are currently parsed. | |
[mysqld_safe] | |
socket = ${MYSQL_DIR}/socket/mysqld.sock | |
nice = 0 | |
[mysqld] | |
user = rof | |
pid-file = ${MYSQL_DIR}/mysqld.pid | |
socket = ${MYSQL_DIR}/socket/mysqld.sock | |
port = ${MYSQL_PORT} | |
basedir = ${MYSQL_DIR}/data | |
datadir = ${MYSQL_DIR}/data/mysql | |
tmpdir = /tmp | |
lc-messages-dir = ${MYSQL_DIR}/share/english | |
skip-external-locking | |
# Instead of skip-networking the default is now to listen only on | |
# localhost which is more compatible and is not less secure. | |
bind-address = 127.0.0.1 | |
# * Fine Tuning | |
max_allowed_packet = 16M | |
thread_stack = 192K | |
thread_cache_size = 8 | |
innodb_use_native_aio = 0 | |
# * Logging and Replication | |
log_error = ${MYSQL_DIR}/log/error.log | |
[mysqldump] | |
quick | |
quote-names | |
max_allowed_packet = 16M | |
[isamchk] | |
key_buffer = 16M | |
" > "${MYSQL_DIR}/my.cnf" | |
"${MYSQL_DIR}/bin/mysqld" --defaults-file="${MYSQL_DIR}/my.cnf" --initialize-insecure | |
( | |
cd "${MYSQL_DIR}" || exit 1 | |
./bin/mysqld_safe --defaults-file="${MYSQL_DIR}/my.cnf" & | |
sleep 10 | |
) | |
"${MYSQL_DIR}/bin/mysql" --defaults-file="${MYSQL_DIR}/my.cnf" -u "${MYSQL_USER}" -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_PASSWORD}';" | |
"${MYSQL_DIR}/bin/mysql" --defaults-file="${MYSQL_DIR}/my.cnf" --version | grep "${MYSQL_VERSION}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment