From 3b1a7ccf4e5c223398d196153bedb36dd19fd9f2 Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 1 Jan 2024 14:48:37 +0100 Subject: [PATCH] Add script 'install_mysql_openssl_111.sh'. Fix error creting variable 'SYSTEMD_ENV_FILE'. --- install_mysql.sh | 27 +- install_mysql_openssl_111.sh | 7147 ++++++++++++++++++++++++++++++++++ 2 files changed, 7167 insertions(+), 7 deletions(-) create mode 100755 install_mysql_openssl_111.sh diff --git a/install_mysql.sh b/install_mysql.sh index ec67d14..c689522 100755 --- a/install_mysql.sh +++ b/install_mysql.sh @@ -833,6 +833,9 @@ if $INSTALL_SYSTEMD_SERVICE ; then MYSQL_SERVICE_FILE="mysqld.service" SYSTEMD_PID_DIR="$MYSQL_DATA_DIR" fi + + SYSTEMD_ENV_FILE="/etc/systemd/system/${MYSQL_DISTRIBUTION,,}-${MYSQL_VERSION}.env" + else if $PARALLEL_INSTALLATION ; then MYSQL_SYSV_INIT_SCRIPT="${MYSQL_DISTRIBUTION,,}-${MYSQL_VERSION}.server" @@ -840,8 +843,6 @@ else else MYSQL_SYSV_INIT_SCRIPT="mysql.server" fi - - SYSTEMD_ENV_FILE="/etc/systemd/system/${MYSQL_DISTRIBUTION,,}-${MYSQL_VERSION}.env" fi @@ -898,6 +899,7 @@ echo "Systemd Unterstützung.....: $SYSTEMD_EXISTS" if $INSTALL_SYSTEMD_SERVICE ; then echo "Starmethode...............: Systemd Service" echo "MySQL Service File........: $MYSQL_SERVICE_FILE" + echo "MySQL Environment File....: $SYSTEMD_ENV_FILE" echo "Systemd pid directory.....: $SYSTEMD_PID_DIR" else echo "Starmethode...............: SysVinit Script" @@ -1020,6 +1022,7 @@ echo "## - Systemd Unterstützung.....: $SYSTEMD_EXISTS" >> ${logdir}/main.log if $INSTALL_SYSTEMD_SERVICE ; then echo "## - Starmethode...............: Systemd Service" >> ${logdir}/main.log echo "## - MySQL Service File........: $MYSQL_SERVICE_FILE" >> ${logdir}/main.log + echo "## - MySQL Environment File....: $SYSTEMD_ENV_FILE" >> ${logdir}/main.log echo "## - Systemd pid directory.....: $SYSTEMD_PID_DIR" >> ${logdir}/main.log else echo "## - Starmethode...............: SysVinit Script" >> ${logdir}/main.log @@ -1070,6 +1073,7 @@ echo "SYMLINK_DATA_DIR=$SYMLINK_DATA_DIR" >> ${logdir}/main.log echo "SYSTEMD_EXISTS=$SYSTEMD_EXISTS" >> ${logdir}/main.log echo "INSTALL_SYSTEMD_SERVICE=$INSTALL_SYSTEMD_SERVICE" >> ${logdir}/main.log echo "MYSQL_SERVICE_FILE=$MYSQL_SERVICE_FILE" >> ${logdir}/main.log +echo "SYSTEMD_ENV_FILE=$SYSTEMD_ENV_FILE" echo "SYSTEMD_PID_DIR=$SYSTEMD_PID_DIR" >> ${logdir}/main.log echo "MYSQL_SYSV_INIT_SCRIPT=$MYSQL_SYSV_INIT_SCRIPT" >> ${logdir}/main.log echo "VSERVER_GUEST=$VSERVER_GUEST" >> ${logdir}/main.log @@ -6048,23 +6052,32 @@ EOF error "Setting open_files_limit (LimitNOFILE) to $(ulimit -Hn) failed!" fi - echononl "Create environmet file fo systemd service.." + echononl "Create environmet file '${SYSTEMD_ENV_FILE}' for systemd service.." echo "" >> ${logdir}/main.log - echo "## - Create environmet file fo systemd service.." >> ${logdir}/main.log + echo "## - Create environmet file '${SYSTEMD_ENV_FILE}' for systemd service.." >> ${logdir}/main.log echo "## -" >> ${logdir}/main.log echo "cat < $SYSTEMD_ENV_FILE MYSQL_HOME=\"$MYSQL_INSTALL_DIR\" EOF " >> ${logdir}/main.log + cat < $SYSTEMD_ENV_FILE +MYSQL_HOME="$MYSQL_INSTALL_DIR" +EOF if [[ $? -eq 0 ]] ; then echo_ok else echo_failed error "Creating environmet file fo systemd service failed!" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" fi - cat < $SYSTEMD_ENV_FILE -MYSQL_HOME="$MYSQL_INSTALL_DIR" -EOF echononl "Add/Replace 'EnvironmentFile' variable at service file .." echo "" >> ${logdir}/main.log diff --git a/install_mysql_openssl_111.sh b/install_mysql_openssl_111.sh new file mode 100755 index 0000000..c94638e --- /dev/null +++ b/install_mysql_openssl_111.sh @@ -0,0 +1,7147 @@ +#!/usr/bin/env bash + +_backup_date="$(date +"%Y-%m-%d-%H%M")" + +_MYSQL_SRC_BASE_DIR=$(dirname $(realpath $0)) + +_MYSQL_LOG_DIR=/var/log/mysql + +_MYSQL_PORT=3306 +_MYSQL_UNIX_SOCKET=/run/mysqld/mysqld.sock + + +_MYSQL_USER=mysql +_MYSQL_GROUP=mysql + +_DISTRIBUTION=Debian + +_VSERVER_GUEST=nein + +_required_debian_packages="default-jdk + libncurses5-dev + libssl-dev + lsb-release + gnutls-dev + libaio-dev + libarchive-dev + libbison-dev + libboost-all-dev + libcrack2-dev + libdw-dev + libelf-dev + libevent-dev + libgroonga-dev + libjemalloc-dev + libjudy-dev + libpam0g-dev + libpcre3-dev + libreadline-dev + libsystemd-dev + libaio-dev + libjemalloc-dev + cpanminus" + + # NOT available since debian bullseye + # + #libreadline-gplv2-dev + +install_additional_debian_packages=true + +_additional_debian_packages_mysql="" +_additional_debian_packages_percona="libperconaserverclient20-dev" +_additional_debian_packages_mariadb="libmariadbclient-dev-compat" + + +_CRONTAB_BAKUP_FILE="$(mktemp)" + +## - Let make use multiple cores (-j) +## - +export MAKEFLAGS=-j$(expr `grep "^processor" /proc/cpuinfo | sort -u | wc -l` + 1) + + +## --- Some functions +## --- +clean_up() { + + # Perform program exit housekeeping + if [[ -s "$_CRONTAB_BAKUP_FILE" ]]; then + crontab -u root $_CRONTAB_BAKUP_FILE + fi + rm -f $_CRONTAB_BAKUP_FILE + exit $1 +} + +echononl(){ + echo X\\c > /tmp/shprompt$$ + if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then + echo "$*\\c" 1>&2 + else + echo -e -n "$*" 1>&2 + fi + rm /tmp/shprompt$$ +} + +fatal(){ + echo "" + echo -e "fataler Fehler: $*" + echo "" + echo -e "\t\033[31m\033[1mInstalllation wird abgebrochen\033[m\033[m" + echo "" + clean_up 1 +} + +error(){ + echo "" + echo -e "\t[ \033[31m\033[1mFehler\033[m ]: $*" + echo "" +} + +warn (){ + echo "" + echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*" + echo "" +} + +info (){ + echo "" + echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*" + echo "" +} + + +echo_ok() { + echo -e "\033[75G[ \033[32mok\033[m ]" + ## echo -e " [ ok ]" +} +echo_failed(){ + echo -e "\033[75G[ \033[1;31mfailed\033[m ]" + ## echo -e " [ failed ]" +} +echo_skipped() { + echo -e "\033[75G[ \033[33m\033[1mskipped\033[m ]" +} +echo_wait(){ + echo -en "\033[75G[ \033[5m\033[1m..\033[m ]" +} +detect_os_1 () { + + if $(which lsb_release > /dev/null 2>&1) ; then + + os_dist="$(lsb_release -i | awk '{print tolower($3)}')" + os_version="$(lsb_release -r | awk '{print tolower($2)}')" + os_codename="$(lsb_release -c | awk '{print tolower($2)}')" + + if [[ "$os_dist" = "debian" ]]; then + if $(echo "$os_version" | grep -q '\.') ; then + os_version=$(echo "$os_version" | cut --delimiter='.' -f1) + fi + fi + + elif [[ -e "/etc/os-release" ]]; then + + . /etc/os-release + + os_dist=$ID + os_version=${os_version_ID} + + fi + + # remove whitespace from os_dist and os_version + os_dist="${os_dist// /}" + os_version="${os_version// /}" + +} + +## --- +## --- END: functions + +trap clean_up SIGHUP SIGINT SIGTERM + +_curdir=`pwd` + + +clear +echo -e "\033[21G\033[32mInstallationsscript für die Mysql Datenbank \033[m" +echo + +## - root user? +## - +if [ "$(id -u)" != "0" ]; then + fatal Skript muss als \"root\" ausgeführt werden +fi + +# - OS supports systemd ? +# - +_systemd="$(which systemd)" +_systemctl="$(which systemctl)" +if [[ -z "$_systemd" ]] && [[ -z "$_systemctl" ]]; then + SYSTEMD_EXISTS=false +else + SYSTEMD_EXISTS=true +fi + +# - Set variable +# - os_dist +# - os_version +# - os_codename +# - +detect_os_1 + + +DISTRIBUTION= +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Um welche Linux Distribution handelt es sich?" +echo "" +echo "[1] Debian" +echo "[2] andere" +echo "" +echononl "Eingabe: " + +while [ "$DISTRIBUTION" != "Debian" -a "$DISTRIBUTION" != "other" ];do + read OPTION + case $OPTION in + 1) DISTRIBUTION="Debian" + ;; + 2) DISTRIBUTION="other" + ;; + *) echo "" + echo -e "\tFalsche Eingabe ! [ 1 = Debian ; 2 = andere ]" + echo "" + echononl "Eingabe:" + ;; + esac +done + +_UPDATE_MYSQL="" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Soll eine vorhanden MySQL Installation geupdateted werden?" +echo "" +echo "[1] Neuinstallation" +echo "[2] Update vorhandener Installation" +echo "[3] Parallelinstallation (nur Neuinstallation)" +echo "" +echononl "Eingabe: " + + +while [ "$_UPDATE_MYSQL" != "update" -a "$_UPDATE_MYSQL" != "new" -a "$_UPDATE_MYSQL" != "parallel" ];do + read OPTION + case $OPTION in + 1) _UPDATE_MYSQL="new" + ;; + 2) _UPDATE_MYSQL="update" + ;; + 3) _UPDATE_MYSQL="parallel" + ;; + *) echo "" + echo -e "\tFalsche Eingabe ! [ 1 = Neuinstallation ; 2 = Update ; 3 = Parallelinstallation]" + echo "" + echononl "Eingabe:" + ;; + esac +done +if [ "$_UPDATE_MYSQL" = "update" ];then + UPDATE_MYSQL=true +else + UPDATE_MYSQL=false +fi + +if [ "$_UPDATE_MYSQL" = "parallel" ];then + PARALLEL_INSTALLATION=true +else + PARALLEL_INSTALLATION=false +fi + +if ! $UPDATE_MYSQL ; then + + MYSQL_DISTRIBUTION= + echo "" + echo -e "\033[32m--\033[m" + echo "" + echo "Select the MySQL distribution to install." + echo "" + echo "[1] MySQL (the original community edition)" + echo "[2] Percona Server for MySQL" + echo "[3] MariaDB" + echo "" + echononl "Eingabe [1/2/3]: " + + while [ "$MYSQL_DISTRIBUTION" != "MySQL" -a "$MYSQL_DISTRIBUTION" != "MariaDB" -a "$MYSQL_DISTRIBUTION" != "Percona" ];do + read OPTION + case $OPTION in + 1) MYSQL_DISTRIBUTION="MySQL" + ;; + 2) MYSQL_DISTRIBUTION="Percona" + ;; + 3) MYSQL_DISTRIBUTION="MariaDB" + ;; + *) echo "" + echo -e "\tFalsche Eingabe ! [ 1 = MySQL ; 2 = Percona ; 3 = MariaDB ]" + echo "" + echononl "Eingabe:" + ;; + esac + done +fi + + +if [[ -n "$(which mysqld)" ]] ; then + + if ! $PARALLEL_INSTALLATION && ! $UPDATE_MYSQL ; then + fatal "Found binary '$(which mysqld)', but you are not in update mode!" + fi + +else + + if $UPDATE_MYSQL ; then + fatal "No installed MySQL server or distribution found, but you are in update mode!" + fi + +fi + +if $UPDATE_MYSQL ; then + + _MYSQLD_VERSION="$(mysqld -V 2>/dev/null)" + + echo "" + echononl "Get current MySQL distribution .." + if [[ -z "$_MYSQLD_VERSION" ]]; then + echo_failed + fatal "No installed MySQL server or distribution found!" + elif [[ "$_MYSQLD_VERSION" =~ MariaDB ]]; then + MYSQL_CUR_DISTRIBUTION="MariaDB" + elif [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ percona- ]]; then + MYSQL_CUR_DISTRIBUTION="Percona" + elif [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ mysql- ]]; then + MYSQL_CUR_DISTRIBUTION="MySQL" + fi + echo_ok + + echononl "Get current MySQL Version.." + CURRENT_VERSION="$(echo $_MYSQLD_VERSION | grep -o -E "[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?" | head -n 1)" + CURRENT_MAIN_VERSION="$(echo $CURRENT_VERSION | cut -d '.' -f1,2)" + if [[ -n "$CURRENT_VERSION" ]]; then + echo_ok + else + echo_failed + fatal "Getting current mysql version failed!" + fi + + info "Currently installed: $MYSQL_CUR_DISTRIBUTION version $CURRENT_VERSION" + + if [[ "$MYSQL_CUR_DISTRIBUTION" = "MariaDB" ]]; then + MYSQL_DISTRIBUTION="MariaDB" + warn "Update with a MySQL distribution other than 'MariaDB' is not supported!" + else + + MYSQL_DISTRIBUTION= + echo "" + echo -e "\033[32m--\033[m" + echo "" + echo "Select the MySQL distribution to install." + echo "" + echo "Note:" + echo " Update the current installation with MariaDB is not supported!" + echo "" + echo "[1] MySQL (the original community edition)" + echo "[2] Percona Server for MySQL" + echo "" + echononl "Eingabe [1/2]: " + + while [ "$MYSQL_DISTRIBUTION" != "MySQL" -a "$MYSQL_DISTRIBUTION" != "Percona" ];do + read OPTION + case $OPTION in + 1) MYSQL_DISTRIBUTION="MySQL" + ;; + 2) MYSQL_DISTRIBUTION="Percona" + ;; + *) echo "" + echo -e "\tFalsche Eingabe ! [ 1 = MySQL ; 2 = Percona ]" + echo "" + echononl "Eingabe:" + ;; + esac + done + + fi +fi + + +#clear +#echo -e "\033[21G\033[32mInstallationsscript für die Mysql Datenbank \033[m" +#echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Gib die Versionsnummer der zu installierenden MySQL-Distribution (${MYSQL_DISTRIBUTION}) an." +echo "" +MYSQL_VERSION= +while [ "X$MYSQL_VERSION" = "X" ] +do + echononl "$MYSQL_DISTRIBUTION Version : " + read MYSQL_VERSION + if [ "X$MYSQL_VERSION" = "X" ]; then + MYSQL_VERSION=$_MYSQL_VERSION + fi + + _MYSQL_INSTALL_DIR=/usr/local/${MYSQL_DISTRIBUTION,,}-$MYSQL_VERSION + _MYSQL_DATA_DIR=/data/${MYSQL_DISTRIBUTION,,}-$MYSQL_VERSION +done +MYSQL_MAIN_VERSION=`echo $MYSQL_VERSION | cut -d '.' -f1,2` +MYSQL_MAJOR_VERSION=`echo $MYSQL_VERSION | cut -d '.' -f1` +MYSQL_MINOR_VERSION=`echo $MYSQL_VERSION | cut -d '.' -f2` +MYSQL_PATCH_LEVEL=`echo $MYSQL_VERSION | cut -d '.' -f3` + +if $UPDATE_MYSQL ; then + if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] && [[ "$MYSQL_MAIN_VERSION" != "$CURRENT_MAIN_VERSION" ]]; then + warn "Only upgrades within minor versions are supported for MariaDB." + fatal "Upgrade MariaDB from version $CURRENT_VERSION to version $MYSQL_VERSION is NOT possible!" + fi +fi + +if [[ "$MYSQL_DISTRIBUTION" = "MySQL" ]]; then + download_base_url="https://dev.mysql.com/get/Downloads/MySQL-${MYSQL_MAIN_VERSION}" + distfile=${MYSQL_DISTRIBUTION,,}-${MYSQL_VERSION}.tar.gz +elif [[ "$MYSQL_DISTRIBUTION" = "Percona" ]] ; then + download_base_url="https://www.percona.com/downloads/Percona-Server-LATEST/Percona-Server-${MYSQL_VERSION}/source/tarball" + distfile="percona-server-${MYSQL_VERSION}.tar.gz" +elif [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] ; then + #download_base_url="http://ftp.hosteurope.de/mirror/archive.mariadb.org/mariadb-${MYSQL_VERSION}/source" + download_base_url="https://archive.mariadb.org/mariadb-${MYSQL_VERSION}/source/" + distfile=${MYSQL_DISTRIBUTION,,}-${MYSQL_VERSION}.tar.gz +fi + + +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Gib den Namen des MySQL Sourceverzeichnisses an." +echo "" +MYSQL_SRC_BASE_DIR= +while [ "X$MYSQL_SRC_BASE_DIR" = "X" ] +do + echononl "MySQL Sourceverzeichnis [${_MYSQL_SRC_BASE_DIR}]: " + read MYSQL_SRC_BASE_DIR + if [ "X$MYSQL_SRC_BASE_DIR" = "X" ]; then + MYSQL_SRC_BASE_DIR=$_MYSQL_SRC_BASE_DIR + fi +done +if [[ "$MYSQL_DISTRIBUTION" = "MySQL" ]]; then + MYSQL_SRC_DIR=${MYSQL_SRC_BASE_DIR}/mysql-$MYSQL_VERSION +elif [[ "$MYSQL_DISTRIBUTION" = "Percona" ]] ; then + MYSQL_SRC_DIR=${MYSQL_SRC_BASE_DIR}/percona-server-$MYSQL_VERSION +elif [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] ; then + MYSQL_SRC_DIR=${MYSQL_SRC_BASE_DIR}/mariadb-$MYSQL_VERSION +fi + +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Gib den Namen des Verzeichnisses in das MySQL installiert werden soll an." +echo "" +MYSQL_INSTALL_DIR= +while [ "X$MYSQL_INSTALL_DIR" = "X" ] +do + echononl "MySQL Installationsverzeichnis [${_MYSQL_INSTALL_DIR}]: " + read MYSQL_INSTALL_DIR + if [ "X$MYSQL_INSTALL_DIR" = "X" ]; then + MYSQL_INSTALL_DIR=$_MYSQL_INSTALL_DIR + LINK=yes + fi + + logdir=${MYSQL_SRC_BASE_DIR}/log-${MYSQL_DISTRIBUTION,,}-$MYSQL_VERSION + +done + +MY_CNF_FILE="${MYSQL_INSTALL_DIR}/etc/my.cnf" + +if $UPDATE_MYSQL ; then + echo "" + echononl "Ermittle Installations Verz. der existierenden MySQL Installation." + + if [[ "$MYSQL_CUR_DISTRIBUTION" = "MySQL" ]]; then + MYSQL_CUR_INSTALL_DIR="$(dirname "$MYSQL_INSTALL_DIR")/mysql-$CURRENT_VERSION" + elif [[ "$MYSQL_CUR_DISTRIBUTION" = "Percona" ]] ; then + MYSQL_CUR_INSTALL_DIR="$(dirname "$MYSQL_INSTALL_DIR")/percona-$CURRENT_VERSION" + elif [[ "$MYSQL_CUR_DISTRIBUTION" = "MariaDB" ]] ; then + MYSQL_CUR_INSTALL_DIR="$(dirname "$MYSQL_INSTALL_DIR")/mariadb-$CURRENT_VERSION" + fi + + + if [[ -d "$MYSQL_CUR_INSTALL_DIR" ]]; then + echo_ok + else + echo_failed + fatal "Kann Installations Verz. der z.Zt. installierten Version nicht finden!" + fi + echo "" +fi + +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Gib den Namen des Verzeichnisses für die MySQL-Datenbanken an." +echo "" +MYSQL_DATA_DIR= +while [ "X$MYSQL_DATA_DIR" = "X" ] +do + echononl "MySQL Datenbankverzeichnis [$_MYSQL_DATA_DIR]: " + read MYSQL_DATA_DIR + if [ "X$MYSQL_DATA_DIR" = "X" ]; then + MYSQL_DATA_DIR=$_MYSQL_DATA_DIR + fi +done + +if $UPDATE_MYSQL ; then + echo "" + + + if [[ "$MYSQL_CUR_DISTRIBUTION" = "MySQL" ]]; then + MYSQL_CUR_DATA_DIR="$(dirname "$MYSQL_DATA_DIR")/mysql-$CURRENT_VERSION" + elif [[ "$MYSQL_CUR_DISTRIBUTION" = "Percona" ]] ; then + MYSQL_CUR_DATA_DIR="$(dirname "$MYSQL_DATA_DIR")/percona-$CURRENT_VERSION" + elif [[ "$MYSQL_CUR_DISTRIBUTION" = "MariaDB" ]] ; then + MYSQL_CUR_DATA_DIR="$(dirname "$MYSQL_DATA_DIR")/mariadb-$CURRENT_VERSION" + fi + + echononl "Ermittle MySQL-Datenbank Verz. der existierenden MySQL Installation." + if [[ -d "$MYSQL_CUR_DATA_DIR" ]]; then + echo_ok + else + echo_failed + fatal "Kann Datenbank Verz. der installierten Version nicht finden!" + fi + echo "" +fi + + +if $PARALLEL_INSTALLATION ; then + _MYSQL_LOG_DIR="$(dirname "$_MYSQL_LOG_DIR")/${MYSQL_DISTRIBUTION,,}-${MYSQL_VERSION}" +fi + +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Gib den Namen des LOG-Verzeichnisses für die MySQL an. !! NICHT für binäre logfiles !!" +echo "" +MYSQL_LOG_DIR= +while [ "X$MYSQL_LOG_DIR" = "X" ] +do + echononl "MySQL LOG Verzeichniss [$_MYSQL_LOG_DIR]: " + read MYSQL_LOG_DIR + if [ "X$MYSQL_LOG_DIR" = "X" ]; then + MYSQL_LOG_DIR=$_MYSQL_LOG_DIR + fi +done + +_mysql_log=${MYSQL_LOG_DIR}/mysql.log +_mysql_error_log=${MYSQL_LOG_DIR}/mysql.err +_mysql_slow_query_log=${MYSQL_LOG_DIR}/slow_query.log +if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]]; then + mariadb_groonga_log=${MYSQL_LOG_DIR}/groonga.log +fi + +if $PARALLEL_INSTALLATION ; then + + declare -i _port=3307 + + while [[ $_port -lt 3316 ]] ; do + if $(netstat -tlnp | grep mysql | grep -q ":$_port" 2> /dev/null) ; then + ((_port++)) + continue + else + _MYSQL_PORT=$_port + break + fi + done + + if $(netstat -tlnp | grep mysql | grep -q ":$_MYSQL_PORT" 2> /dev/null) ; then + fatal "To many parallel installations" + fi + +fi + +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Gib den TCP Port für MySQL an (voreingestell \"${_MYSQL_PORT}\")." +echo "" +MYSQL_PORT= +while [ "X$MYSQL_PORT" = "X" ] +do + echononl "MySQL TCP Port [$_MYSQL_PORT]: " + read MYSQL_PORT + if [ "X$MYSQL_PORT" = "X" ]; then + MYSQL_PORT=$_MYSQL_PORT + fi +done + + +if $PARALLEL_INSTALLATION ; then + _MYSQL_UNIX_SOCKET="/tmp/${MYSQL_DISTRIBUTION,,}-${MYSQL_VERSION}.sock" +fi + +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Gib den Unix Socket für MySQL an (voreingestell \"${_MYSQL_UNIX_SOCKET}\")." +echo "" +MYSQL_UNIX_SOCKET= +while [ "X$MYSQL_UNIX_SOCKET" = "X" ] +do + echononl "MySQL UNIX Socket [$_MYSQL_UNIX_SOCKET]: " + read MYSQL_UNIX_SOCKET + if [ "X$MYSQL_UNIX_SOCKET" = "X" ]; then + MYSQL_UNIX_SOCKET=$_MYSQL_UNIX_SOCKET + fi +done +MYSQL_RUN_DIR="$(dirname "$MYSQL_UNIX_SOCKET")" + + +# Unix socket file which X Plugin uses for connections. +# +if [[ "${MYSQL_DISTRIBUTION,,}" = 'mysql' ]] && [[ ${MYSQL_MAJOR_VERSION} -ge 8 ]] ; then + BASE_NAME_UNIX_SOCKET="$(basename ${MYSQL_UNIX_SOCKET})" + MYSQL_X_UNIX_SOCKET="$(dirname ${MYSQL_UNIX_SOCKET})/${BASE_NAME_UNIX_SOCKET%.*}x.${BASE_NAME_UNIX_SOCKET##*.}" + MYSQL_X_PORT="${MYSQL_PORT}0" +else + MYSQL_X_UNIX_SOCKET="" + MYSQL_X_PORT="" +fi + +echo "" +echo "--" +echo "" +echo "Gib den User-Namen und die User-Gruppe unter dem der MySQL-Daemon laufen soll an." +echo "" +MYSQL_USER= +while [ "X$MYSQL_USER" = "X" ] +do + echononl "MySQL-User [${_MYSQL_USER}]: " + read MYSQL_USER + if [ "X$MYSQL_USER" = "X" ]; then + MYSQL_USER=$_MYSQL_USER + fi +done +MYSQL_GROUP= +while [ "X$MYSQL_GROUP" = "X" ] +do + echononl "MySQL-Gruppe [$MYSQL_USER]: " + read MYSQL_GROUP + if [ "X$MYSQL_GROUP" = "X" ]; then + MYSQL_GROUP=$MYSQL_USER + fi +done + +#clear +#echo -e "\033[21G\033[32mInstallationsscript für die Mysql Datenbank \033[m" + +echo "" +echo -e "\033[32m--\033[m" +echo "" +if ! $UPDATE_MYSQL ; then + echo "Gib ein Passwort für den root user an.." +else + echo "Gib das 'root' Passwort der bestehenden Installation an" +fi +echo "" +_MYSQL_ROOT_PW_1="X" +_MYSQL_ROOT_PW_2="Y" +while [ "$_MYSQL_ROOT_PW_1" != "$_MYSQL_ROOT_PW_2" ] +do + echononl "Passworteingabe: " + read -s _MYSQL_ROOT_PW_1 + echo + if [ "X$_MYSQL_ROOT_PW_1" = "X" ]; then + echo -e "\n\t\033[33m\033[1mPassworteingabe erforderlich!\033[m\n" + continue + fi + echononl "Passwortwiederholung: " + read -s _MYSQL_ROOT_PW_2 + echo + if [ "X$_MYSQL_ROOT_PW_2" = "X" ]; then + echo -e "\n\t\033[33m\033[1mPasswortwiederholung erforderlich!\033[m\n" + continue + fi + if [ "$_MYSQL_ROOT_PW_1" != "$_MYSQL_ROOT_PW_2" ];then + echo -e "\n\t\033[33m\033[1mPassworteingaben sind nicht identisch!\033[m\n" + else + if $UPDATE_MYSQL ; then + if $(pgrep mysqld_safe > /dev/null 2>&1) || $(pgrep mysqld > /dev/null 2>&1); then + if $(mysql --user="root" --password="$_MYSQL_ROOT_PW_1" -N -s -e 'quit' > /dev/null 2>&1) ; then + MYSQL_ROOT_PW=$_MYSQL_ROOT_PW_1 + else + echo -e "\n\t\033[33m\033[1mFalsches Passwort\033[m\n" + _MYSQL_ROOT_PW_1="" + fi + else + MYSQL_ROOT_PW=$_MYSQL_ROOT_PW_1 + fi + else + MYSQL_ROOT_PW=$_MYSQL_ROOT_PW_1 + fi + fi +done + +if $PARALLEL_INSTALLATION ; then + SYMLINK_INSTALL_DIR=false + SYMLINK_DATA_DIR=false +fi + + +if ! $PARALLEL_INSTALLATION ; then + + __SYMLINK_INSTALL_DIR=ja + __SYMLINK_DATA_DIR=ja + + echo -e "\033[32m--\033[m" + echo "" + echo "Symlinks:" + echo "" + echo " - Setze Sysmlink for das Installationsverzeichnis `dirname $MYSQL_INSTALL_DIR`/mysql" + echo " - Setze Sysmlink for das Datenverzeichnis `dirname $MYSQL_DATA_DIR`/mysql" + echo "" + + echo "" + _SYMLINK_INSTALL_DIR="" + echononl "Sysmlink für das Installationsverzeichnis? (ja/nein) [${__SYMLINK_INSTALL_DIR}]: " + read _SYMLINK_INSTALL_DIR + if [ "X$_SYMLINK_INSTALL_DIR" = "X" ];then + _SYMLINK_INSTALL_DIR=$__SYMLINK_INSTALL_DIR + fi + + _SYMLINK_INSTALL_DIR="$(echo "$_SYMLINK_INSTALL_DIR" | tr '[:upper:]' '[:lower:]')" + while [ "$_SYMLINK_INSTALL_DIR" != "ja" -a "$_SYMLINK_INSTALL_DIR" != "nein" ]; do + echononl "Falsche Eingabe. (ja/nein): " + read _SYMLINK_INSTALL_DIR + done + if [ "$_SYMLINK_INSTALL_DIR" = "ja" -o "$_SYMLINK_INSTALL_DIR" = "Ja" ]; then + SYMLINK_INSTALL_DIR=true + else + SYMLINK_INSTALL_DIR=false + fi + + echo "" + _SYMLINK_DATA_DIR="" + echononl "Sysmlink für das Datenverzeichnis? (ja/nein) [${__SYMLINK_DATA_DIR}]: " + read _SYMLINK_DATA_DIR + if [ "X$_SYMLINK_DATA_DIR" = "X" ];then + _SYMLINK_DATA_DIR=$__SYMLINK_DATA_DIR + fi + + __SYMLINK_DATA_DIR="$(echo "$_SYMLINK_DATA_DIR" | tr '[:upper:]' '[:lower:]')" + while [ "$_SYMLINK_DATA_DIR" != "ja" -a "$_SYMLINK_DATA_DIR" != "nein" ]; do + echononl "Falsche Eingabe. (ja/nein): " + read _SYMLINK_DATA_DIR + done + if [ "$_SYMLINK_DATA_DIR" = "ja" -o "$_SYMLINK_DATA_DIR" = "Ja" ]; then + SYMLINK_DATA_DIR=true + else + SYMLINK_DATA_DIR=false + fi + +fi # if ! $PARALLEL_INSTALLATION ; then + + + +OK= +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Ist dies ein VServer Gastsystem?" +echo "" +echononl "VServer Gastsystem (ja/nein) [$_VSERVER_GUEST]: " +read OK +if [ "X$OK" = "X" ]; then + OK=$_VSERVER_GUEST +fi +OK=`echo "$OK" | tr '[:upper:]' '[:lower:]'` +while [ "X$OK" != "Xja" -a "X$OK" != "Xnein" ]; do + echo "" + echononl "\twrong entry! [ja/nein]: " + read OK + OK=`echo "$OK" | tr '[:upper:]' '[:lower:]'` +done +if [ "$OK" = "ja" ]; then + SYSTEMD_EXISTS=false + VSERVER_GUEST=true +else + VSERVER_GUEST=false +fi + +if [[ "$MYSQL_MAJOR_VERSION" -lt 5 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 5 ]] && [[ "$MYSQL_MINOR_VERSION" -lt 7 ]] ) ; then + INSTALL_SYSTEMD_SERVICE=false +else + if $SYSTEMD_EXISTS ; then + INSTALL_SYSTEMD_SERVICE="" + echo "" + echo -e "\033[32m--\033[m" + echo "" + echo "Wie soll der MySQL Datenbank Service getsartet werden?" + echo "" + if $PARALLEL_INSTALLATION ; then + echo "[1] SysVinit script ${MYSQL_DISTRIBUTION,,}-${MYSQL_VERSION}.server" + echo -e "[2] \033[37m\033[1mSystemd service ${MYSQL_DISTRIBUTION,,}-${MYSQL_VERSION}.service\033[m" + else + echo "[1] SysVinit script mysql.server" + echo -e "[2] \033[37m\033[1mSystemd service mysqld.service\033[m" + fi + echo "" + echo "" + echo "Type a number or press to choose highlighted value" + echo "" + echononl "Eingabe: " + + while [[ "$INSTALL_SYSTEMD_SERVICE" != "true" ]] && [[ "$INSTALL_SYSTEMD_SERVICE" != "false" ]]; do + + #while [[ -z "$INSTALL_SYSTEMD_SERVICE" ]];do + read OPTION + case $OPTION in + 1) INSTALL_SYSTEMD_SERVICE=false + ;; + 2) INSTALL_SYSTEMD_SERVICE=true + ;; + '') INSTALL_SYSTEMD_SERVICE=true + ;; + *) echo "" + echo -e "\tFalsche Eingabe ! [ 1 = Systemd Service ; 2 = SysVinit Script ]" + echo "" + echononl "Eingabe:" + ;; + esac + done + + else + INSTALL_SYSTEMD_SERVICE=false + fi +fi + +MYSQL_SERVICE_FILE="" +MYSQL_SYSV_INIT_SCRIPT="" +SYSTEMD_PID_DIR="$(dirname "$MYSQL_UNIX_SOCKET")" +if $INSTALL_SYSTEMD_SERVICE ; then + + if $PARALLEL_INSTALLATION ; then + MYSQL_SERVICE_FILE="${MYSQL_DISTRIBUTION,,}-${MYSQL_VERSION}.service" + SYSTEMD_PID_DIR="$MYSQL_DATA_DIR" + elif [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]]; then + MYSQL_SERVICE_FILE="mariadb.service" + else + MYSQL_SERVICE_FILE="mysqld.service" + SYSTEMD_PID_DIR="$MYSQL_DATA_DIR" + fi + + SYSTEMD_ENV_FILE="/etc/systemd/system/${MYSQL_DISTRIBUTION,,}-${MYSQL_VERSION}.env" + +else + if $PARALLEL_INSTALLATION ; then + MYSQL_SYSV_INIT_SCRIPT="${MYSQL_DISTRIBUTION,,}-${MYSQL_VERSION}.server" + SUPPORT_FILE_INIT_SCRIPT="mysql.server" + else + MYSQL_SYSV_INIT_SCRIPT="mysql.server" + fi +fi + + +clear +echo -e "\033[21G\033[32mStarte Installation mit folgenden Parametern:\033[m" +echo "" +if ! $UPDATE_MYSQL ; then + if $PARALLEL_INSTALLATION ; then + echo -e "-- \033[33m\033[1mParallelinstallation\033[m --" + else + echo -e "-- \033[33m\033[1mNeusistallation\033[m --" + fi +else + echo -e "-- \033[33m\033[1mUpdate\033[m (Ersetzen einer vorhandenen Installation) --" + echo "" + echo "Current MySQL Version.....: $CURRENT_VERSION" + echo "Current data dir..........: $MYSQL_CUR_DATA_DIR" + echo "Current installation dir..: $MYSQL_CUR_INSTALL_DIR" + echo "" +fi +echo "" +echo "Linuxdistribution.........: $DISTRIBUTION" +echo "" +echo "MySQL Distribution........: $MYSQL_DISTRIBUTION" +echo "MySQL Versionsnummer......: $MYSQL_VERSION" +echo " MySQL Main Verion.......: $MYSQL_MAIN_VERSION" +echo " MySQL Major Verion......: $MYSQL_MAJOR_VERSION" +echo " MySQL Minor Verion......: $MYSQL_MINOR_VERSION" +echo " MySQL Patch Leveln......: $MYSQL_PATCH_LEVEL" +echo "" +echo "Download base URL.........: $download_base_url" +echo "Download file.............: $distfile" +echo "" +echo "Source Basis Verzeichnis..: $MYSQL_SRC_BASE_DIR" +echo "" +echo "Sourcecodeverzeicnis......: $MYSQL_SRC_DIR" +echo "Installationsverzeichnis..: $MYSQL_INSTALL_DIR" +echo "Default file 'my.cnf'.....: $MY_CNF_FILE" +echo "Datenbankverzeichnis......: $MYSQL_DATA_DIR" +echo "Log Verzeichnis...........: $MYSQL_LOG_DIR" +echo "TCP Port..................: $MYSQL_PORT" +echo "Unix Socket...............: $MYSQL_UNIX_SOCKET" +if [[ -n "$MYSQL_X_UNIX_SOCKET" ]] ; then + echo " Unix Socket (X Plugin)..: $MYSQL_X_UNIX_SOCKET" + echo " TCP Port (X Plugin).....: $MYSQL_X_PORT" +fi +echo "MySQL-User................: $MYSQL_USER" +echo "MySQL-Gruppe..............: $MYSQL_GROUP" +echo "" +echo "Symlink Installationsverz.: $SYMLINK_INSTALL_DIR" +echo "Symlink Datenverzeichnis..: $SYMLINK_DATA_DIR" +echo "" +echo "Systemd Unterstützung.....: $SYSTEMD_EXISTS" +if $INSTALL_SYSTEMD_SERVICE ; then + echo "Starmethode...............: Systemd Service" + echo "MySQL Service File........: $MYSQL_SERVICE_FILE" + echo "MySQL Environment File....: $SYSTEMD_ENV_FILE" + echo "Systemd pid directory.....: $SYSTEMD_PID_DIR" +else + echo "Starmethode...............: SysVinit Script" + echo "MySQL SysyVinit Script....: $MYSQL_SYSV_INIT_SCRIPT" +fi +echo "" +echo "VServer guest system......: $VSERVER_GUEST" +echo "" +echononl "einverstanden [ja/nein]: " +read OK +while [ "X$OK" != "Xja" -a "X$OK" != "XJa" -a "X$OK" != "Xnein" -a "X$OK" != "XNein" ] +do + echononl "falsche Angabe! [ja/nein]: " + read OK +done +[ $OK = "ja" -o $OK = "Ja" ] || fatal wiederhole Installation zur Eingabe anderer Parameter + + + +### - Sorcecode Verzeichnis vorhanden? +### - +#if [ ! -d ${MYSQL_SRC_BASE_DIR} ] ; then +# fatal "Kann MySQL Sourcecode Verzeichnis \"${MYSQL_SRC_BASE_DIR}\" nicht finden." +#fi +# +# +### - Sorcecode vorhanden? +### - +#if [ ! -f ${MYSQL_SRC_BASE_DIR}/$distfile ] ; then +# +# echo "" +# +# echononl "Download $distfile ..." +# wget -O ${MYSQL_SRC_BASE_DIR}/$distfile https://dev.mysql.com/get/Downloads/MySQL-${MYSQL_MAIN_VERSION}/$distfile 2>/dev/null +# +# if [ "$?" = "0" ]; then +# echo_ok +# else +# echo_failed +# fatal "Downloading $distfile (https://dev.mysql.com/get/Downloads/MySQL-${MYSQL_MAIN_VERSION}/$distfile) Fehlgeschlagen." +# fi +#fi +# +#echo "" +#echo "" + + +## - Erstelle Logverzeichnis +## - +if [ -d $logdir ]; then + echononl "Verschiebe exitierendes Logverzeichnis ..." + mv "$logdir" "${logdir}.$_backup_date" + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal Kann Logverzeichnis \"${logdir}\" nicht verschieben.. + fi +fi + +echononl "Erstelle Logverzeichnis \"${logdir}\".." +mkdir -p $logdir > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal Kann Logverzeichnis \"${logdir}\" nicht erstellen.. +fi +touch ${logdir}/main.log +echo -e "## - Starte Installation mit folgenden Parametern:" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +if ! $UPDATE_MYSQL ; then + if $PARALLEL_INSTALLATION ; then + echo "## - Parallelinstallation" >> ${logdir}/main.log + else + echo "## - Neusistallation" >> ${logdir}/main.log + fi +else + echo "## - Update (Ersetzen einer vorhandenen Installation)" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## - Current MySQL Version.....: $CURRENT_VERSION" >> ${logdir}/main.log + echo "## - Current installation dir..: $MYSQL_CUR_INSTALL_DIR" >> ${logdir}/main.log + echo "## - Current data dir..........: $MYSQL_CUR_DATA_DIR" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log +fi +echo "## -" >> ${logdir}/main.log +echo "## - Linuxdistribution.........: $DISTRIBUTION" >> ${logdir}/main.log +echo "## - " >> ${logdir}/main.log +echo "## - MySQL Distribution........: $MYSQL_DISTRIBUTION" >> ${logdir}/main.log +echo "## - MySQL Versionsnummer......: $MYSQL_VERSION" >> ${logdir}/main.log +echo "## - MySQL Main Verion.......: $MYSQL_MAIN_VERSION" >> ${logdir}/main.log +echo "## - MySQL Major Verion......: $MYSQL_MAJOR_VERSION" >> ${logdir}/main.log +echo "## - MySQL Minor Verion......: $MYSQL_MINOR_VERSION" >> ${logdir}/main.log +echo "## - MySQL Patch Leveln......: $MYSQL_PATCH_LEVEL" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "## - Download base URL.........: $download_base_url" >> ${logdir}/main.log +echo "## - Download file.............: $distfile" >> ${logdir}/main.log +echo "## - " >> ${logdir}/main.log +echo "## - Source Basis Verzeichnis..: $MYSQL_SRC_BASE_DIR" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "## - Sourcecodeverzeicnis......: $MYSQL_SRC_DIR" >> ${logdir}/main.log +echo "## - Installationsverzeichnis..: $MYSQL_INSTALL_DIR" >> ${logdir}/main.log +echo "## - Default file 'my.cnf'.....: $MY_CNF_FILE" >> ${logdir}/main.log +echo "## - Datenbankverzeichnis......: $MYSQL_DATA_DIR" >> ${logdir}/main.log +echo "## - Log Verzeichnis...........: $MYSQL_LOG_DIR" >> ${logdir}/main.log +echo "## - TCP Port..................: $MYSQL_PORT" >> ${logdir}/main.log +echo "## - Unix Socket...............: $MYSQL_UNIX_SOCKET" >> ${logdir}/main.log +if [[ -n "$MYSQL_X_UNIX_SOCKET" ]] ; then + echo "## - Unix Socket (X Plugin)..: $MYSQL_X_UNIX_SOCKET" >> ${logdir}/main.log + echo "## - TCP Port (X Plugin).....: $MYSQL_X_PORT" >> ${logdir}/main.log +fi +echo "## - MySQL-User................: $MYSQL_USER" >> ${logdir}/main.log +echo "## - MySQL-Gruppe..............: $MYSQL_GROUP" >> ${logdir}/main.log +echo "## - " >> ${logdir}/main.log +echo "## - Symlink Installationsverz.: $SYMLINK_INSTALL_DIR" >> ${logdir}/main.log +echo "## - Symlink Datenverzeichnis..: $SYMLINK_DATA_DIR" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "## - Systemd Unterstützung.....: $SYSTEMD_EXISTS" >> ${logdir}/main.log +if $INSTALL_SYSTEMD_SERVICE ; then + echo "## - Starmethode...............: Systemd Service" >> ${logdir}/main.log + echo "## - MySQL Service File........: $MYSQL_SERVICE_FILE" >> ${logdir}/main.log + echo "## - MySQL Environment File....: $SYSTEMD_ENV_FILE" >> ${logdir}/main.log + echo "## - Systemd pid directory.....: $SYSTEMD_PID_DIR" >> ${logdir}/main.log +else + echo "## - Starmethode...............: SysVinit Script" >> ${logdir}/main.log + echo "## - MySQL SysyVinit Script....: $MYSQL_SYSV_INIT_SCRIPT" >> ${logdir}/main.log +fi +echo "## -" >> ${logdir}/main.log +echo "## - VServer guest system......: $VSERVER_GUEST" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log + +echo "UPDATE_MYSQL=$UPDATE_MYSQL" >> ${logdir}/main.log +echo "PARALLEL_INSTALLATION=$PARALLEL_INSTALLATION" +if $UPDATE_MYSQL ; then + echo "CURRENT_VERSION=$CURRENT_VERSION" >> ${logdir}/main.log + echo "MYSQL_CUR_DATA_DIR=$MYSQL_CUR_DATA_DIR" >> ${logdir}/main.log + echo "MYSQL_CUR_INSTALL_DIR=$MYSQL_CUR_INSTALL_DIR" >> ${logdir}/main.log +fi +echo "" >> ${logdir}/main.log +echo "DISTRIBUTION=$DISTRIBUTION" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "MYSQL_DISTRIBUTION=$MYSQL_DISTRIBUTION" >> ${logdir}/main.log +echo "MYSQL_VERSION=$MYSQL_VERSION" >> ${logdir}/main.log +echo "MYSQL_MAIN_VERSION=$MYSQL_MAIN_VERSION" >> ${logdir}/main.log +echo "MYSQL_MAJOR_VERSION=$MYSQL_MAJOR_VERSION" >> ${logdir}/main.log +echo "MYSQL_MINOR_VERSION=$MYSQL_MINOR_VERSION" >> ${logdir}/main.log +echo "MYSQL_PATCH_LEVEL=$MYSQL_PATCH_LEVEL" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "download_base_url=$download_base_url" >> ${logdir}/main.log +echo "distfile=$distfile" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "MYSQL_SRC_BASE_DIR=$MYSQL_SRC_BASE_DIR" >> ${logdir}/main.log +echo "MYSQL_SRC_DIR=$MYSQL_SRC_DIR" >> ${logdir}/main.log +echo "MYSQL_INSTALL_DIR=$MYSQL_INSTALL_DIR" >> ${logdir}/main.log +echo "MY_CNF_FILE=$MY_CNF_FILE" >> ${logdir}/main.log +echo "MYSQL_DATA_DIR=$MYSQL_DATA_DIR" >> ${logdir}/main.log +echo "MYSQL_LOG_DIR=$MYSQL_LOG_DIR" >> ${logdir}/main.log +echo "MYSQL_PORT=$MYSQL_PORT" >> ${logdir}/main.log +echo "MYSQL_UNIX_SOCKET=$MYSQL_UNIX_SOCKET" >> ${logdir}/main.log +if [[ -n "$MYSQL_X_UNIX_SOCKET" ]] ; then + echo "MYSQL_X_UNIX_SOCKET=$MYSQL_X_UNIX_SOCKET" + echo "MYSQL_X_PORT=$MYSQL_X_PORT" +fi +echo "MYSQL_USER=$MYSQL_USER" >> ${logdir}/main.log +echo "MYSQL_GROUP=$MYSQL_GROUP" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "SYMLINK_INSTALL_DIR=$SYMLINK_INSTALL_DIR" >> ${logdir}/main.log +echo "SYMLINK_DATA_DIR=$SYMLINK_DATA_DIR" >> ${logdir}/main.log +echo "SYSTEMD_EXISTS=$SYSTEMD_EXISTS" >> ${logdir}/main.log +echo "INSTALL_SYSTEMD_SERVICE=$INSTALL_SYSTEMD_SERVICE" >> ${logdir}/main.log +echo "MYSQL_SERVICE_FILE=$MYSQL_SERVICE_FILE" >> ${logdir}/main.log +echo "SYSTEMD_ENV_FILE=$SYSTEMD_ENV_FILE" +echo "SYSTEMD_PID_DIR=$SYSTEMD_PID_DIR" >> ${logdir}/main.log +echo "MYSQL_SYSV_INIT_SCRIPT=$MYSQL_SYSV_INIT_SCRIPT" >> ${logdir}/main.log +echo "VSERVER_GUEST=$VSERVER_GUEST" >> ${logdir}/main.log + + +echo "_mysql_log=$_mysql_log" >> ${logdir}/main.log +echo "_mysql_error_log=$_mysql_error_log" >> ${logdir}/main.log +echo "_mysql_slow_query_log=$_mysql_slow_query_log" >> ${logdir}/main.log +if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]]; then + echo "mariadb_groonga_log=$mariadb_groonga_log" >> ${logdir}/main.log +fi + + +if ! $PARALLEL_INSTALLATION ; then + + MYSQL_INIT_SCRIPT="" + MYSQLD_SERVICE_FILE="" + if $SYSTEMD_EXISTS ; then + if [[ -f "/etc/systemd/system/$MYSQL_SERVICE_FILE" ]]; then + MYSQLD_SERVICE_FILE="${MYSQL_SERVICE_FILE}" + else + # - Is Service exclusive controlled by systemd + # - + if systemctl -t service list-unit-files \ + | grep -e "^mysql" \ + | grep -q -E "(enabled|disabled|generated)" 2> /devnull ; then + + MYSQLD_SERVICE_FILE=$(systemctl -t service list-unit-files \ + | grep -e "^mysql" \ + | awk '{print$1}' \ + | head -1) + fi + fi + + fi + + if [[ -f "/etc/systemd/system/$MYSQL_SERVICE_FILE" ]]; then + MYSQL_INIT_SCRIPT="${MYSQL_SYSV_INIT_SCRIPT}" + elif [[ -x "$(realpath /etc/init.d/mysql.server)" ]]; then + MYSQL_INIT_SCRIPT="mysql.server" + elif [[ -x "$(realpath /etc/init.d/mysql)" ]]; then + MYSQL_INIT_SCRIPT="mysql" + fi + + if [[ -z "$MYSQL_INIT_SCRIPT" ]] && [[ -z "$MYSQLD_SERVICE_FILE" ]] && $UPDATE_MYSQL ; then + error "Kein start/stop Sevice File/ Init Script gefunden.." + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + +fi # if ! $PARALLEL_INSTALLATION ; then + + +## --- +## - Download sources +## --- + +echo "" +echo "" +echo -e "\033[37m\033[1mDownload sources..\033[m" +echo "" + +echo "" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log +echo "## - Download sources" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log + +## - Sorcecode Verzeichnis vorhanden? +## - +if [ ! -d ${MYSQL_SRC_BASE_DIR} ] ; then + fatal "Kann MySQL Sourcecode Verzeichnis \"${MYSQL_SRC_BASE_DIR}\" nicht finden." +fi + +## - Sorcecode vorhanden? +## - +echononl "Download $distfile .." +if [ ! -f ${MYSQL_SRC_BASE_DIR}/$distfile ] ; then + + echo "" >> ${logdir}/main.log + echo "## - Download $distfile .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "wget -O ${MYSQL_SRC_BASE_DIR}/$distfile ${download_base_url}/$distfile" >> ${logdir}/main.log + wget -O ${MYSQL_SRC_BASE_DIR}/$distfile ${download_base_url}/$distfile 2>/dev/null + + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal "Downloading $distfile (${download_base_url}/$distfile) Fehlgeschlagen." + fi +else + echo_skipped +fi + + +## ----- +## - Doing some pre-installation tasks +## ----- + +echo "" +echo "" +echo -e "\033[37m\033[1mDoing some pre-installation tasks..\033[m" +echo "" + +echo "" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log +echo "## - Doing some pre-installation tasks" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log + + +echononl "Adding Group \"$MYSQL_GROUP\".." +if cat /etc/group | grep -e "^${MYSQL_GROUP}:" > /dev/null 2>&1 ; then + echo_skipped +else + echo "" >> ${logdir}/main.log + echo "## - Erstelle Gruppe \"$MYSQL_GROUP\"" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "groupadd -r $MYSQL_GROUP" >> ${logdir}/main.log + groupadd -r $MYSQL_GROUP >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal Kann Gruppe \"${MYSQL_GROUP}\" nicht erstellen.. + fi +fi + +echononl "Adding User \"$MYSQL_USER\".." +if id -u $MYSQL_USER > /dev/null 2>&1; then + echo_skipped +else + echo "" >> ${logdir}/main.log + echo "## - Erstelle User \"$MYSQL_USER\"" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "useradd -r -M -d /noexistent -s /bin/false -g $MYSQL_GROUP $MYSQL_USER" >> ${logdir}/main.log + useradd -r -M -d /noexistent -s /bin/false -g $MYSQL_GROUP $MYSQL_USER >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal Kann User \"${MYSQL_USER}\" nicht erstellen.. + fi +fi + +## - Disable crontab for user root +## - +_crontab_found=false +echononl "Backup crontab" +echo "" >> ${logdir}/main.log +echo "## - Backup crontab" >> ${logdir}/main.log +echo "## - " >> ${logdir}/main.log +echo "crontab -u root -l > $_CRONTAB_BAKUP_FILE" >> ${logdir}/main.log +crontab -u root -l >> $_CRONTAB_BAKUP_FILE 2>> ${logdir}/main.log +if [ "$?" = "0" ]; then + echo_ok + _crontab_found=true +else + if [[ ! -s "$_CRONTAB_BAKUP_FILE" ]] ; then + echo_skipped + warn "No crontab for user 'root'found." + else + echo_failed + error "Backup crontab failed" + fi +fi + +if $_crontab_found ; then + echononl "Disable crontab for user root" + echo "" >> ${logdir}/main.log + echo "## - Disable crontab for user root" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "crontab -r -u root" >> ${logdir}/main.log + crontab -r -u root >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi +fi + +## - Stop MySQL Service if running +## - +echononl "Stop MySQL Service.." +if $PARALLEL_INSTALLATION || ! $UPDATE_MYSQL; then + echo_skipped +else + _pid_string="${MYSQL_CUR_DISTRIBUTION,,}-${CURRENT_VERSION}/bin/(mysqld_safe |mysqld )" + PIDS="$(ps aux | grep -E "$_pid_string" | grep -v grep | awk '{print$2}')" + + if [[ "X${PIDS}X" != "XX" ]];then + echo "" >> ${logdir}/main.log + echo "## - Stop MySQL Service" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + if $SYSTEMD_EXISTS ; then + if [[ -n "$MYSQLD_SERVICE_FILE" ]] ; then + echo "systemctl stop ${MYSQLD_SERVICE_FILE}" >> ${logdir}/main.log + systemctl stop ${MYSQLD_SERVICE_FILE} >> ${logdir}/main.log 2>&1 + else + echo "systemctl stop ${MYSQL_INIT_SCRIPT}" >> ${logdir}/main.log + systemctl stop ${MYSQL_INIT_SCRIPT} >> ${logdir}/main.log 2>&1 + fi + else + echo "/etc/init.d/$MYSQL_INIT_SCRIPT stop" >> ${logdir}/main.log + /etc/init.d/$MYSQL_INIT_SCRIPT stop >> ${logdir}/main.log 2>&1 + fi + + sleep 5 + + PIDS="$(ps aux | grep -E "$_pid_string" | grep -v grep | awk '{print$2}')" + if [[ -z "${PIDS}" ]]; then + echo_ok + else + echo_failed + + echononl "Abbruch (kill -9) aller mysqld Prozesse.." + echo "" >> ${logdir}/main.log + echo "## - Abbruch (kill -9) aller mysqld Prozesse" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + + declare -i i=0 + + while [[ -n "$PIDS" ]] ; do + + if [[ $i -gt 10 ]]; then + echo_failed + error "Killing remaining MySQL processes failed!" + break + fi + + for _PID in $PIDS ; do + echo "kill -9 $_PID" >> ${logdir}/main.log + kill -9 $_PID >> ${logdir}/main.log 2>&1 + done + + sleep 2 + + PIDS="$(ps aux | grep -E "(bin/mysqld_safe |bin/mysqld )" | grep -v grep | awk '{print$2}')" + (( i++ )) + done + + [[ $i -le 10 ]] && echo_ok + fi + else + echo_skipped + fi + +fi # if $PARALLEL_INSTALLATION ; then + +## ----- +## - Deactivate starting MySQL database service at boot time and +## - cleanup System from SysVinit script and/or Systemd service file +## ----- + +if ! $PARALLEL_INSTALLATION ; then + + if [[ -n "$MYSQL_INIT_SCRIPT" ]] || [[ -n "$MYSQLD_SERVICE_FILE" ]]; then + echo "" + echo "" + echo -e "\033[37m\033[1mDeactivate starting MySQL database service at boot time and" + echo -e "cleanup System from SysVinit script and/or Systemd service file.\033[m" + echo "" + + echo "" >> ${logdir}/main.log + echo "" >> ${logdir}/main.log + echo "## -----" >> ${logdir}/main.log + echo "## - Deactivate starting MySQL database service at boot time and" >> ${logdir}/main.log + echo "## - cleanup System from SysVinit script and/or Systemd service file." >> ${logdir}/main.log + echo "## -----" >> ${logdir}/main.log + fi + + if [[ -n "$MYSQL_INIT_SCRIPT" ]] ; then + + if [[ -f "/etc/init.d/$MYSQL_INIT_SCRIPT" ]]; then + echononl "Entferne existierendes Initskript" + echo "" >> ${logdir}/main.log + echo "## - Entferne existierendes Initskript" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "rm -f /etc/init.d/$MYSQL_INIT_SCRIPT" >> ${logdir}/main.log + rm -f /etc/init.d/$MYSQL_INIT_SCRIPT >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal "Kann existierendes Initskript nicht entfernen." + fi + fi + + ## - Entferne symbolische Links aus den Run Level Verzeichnissen + ## - + echononl "Entferne symbolische Links aus den Run Level Verzeichnissen" + echo "" >> ${logdir}/main.log + echo "## - Entferne symbolische Links aus den Run Level Verzeichnissen" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "update-rc.d -f $MYSQL_INIT_SCRIPT remove" >> ${logdir}/main.log + update-rc.d -f $MYSQL_INIT_SCRIPT remove >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal "Kann symbolische Links (Run Level Verzeichnisse) nicht entfernen." + fi + fi + + if [[ -n "$MYSQLD_SERVICE_FILE" ]]; then + + echononl "Deaktiviere Systemd Service \"$MYSQLD_SERVICE_FILE\".." + echo "" >> ${logdir}/main.log + echo "## - Deaktiviere Systemd Service \"$MYSQLD_SERVICE_FILE\"" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "systemctl disable \"$MYSQLD_SERVICE_FILE\"" >> ${logdir}/main.log + + systemctl disable "$MYSQLD_SERVICE_FILE" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Kann Systemd Service \"$MYSQLD_SERVICE_FILE\" nicht deaktivieren!" + fi + + echononl "Entferne Systemd Service \"etc/systemd/system/${MYSQLD_SERVICE_FILE}\".." + echo "" >> ${logdir}/main.log + echo "## - Enferne datei \"/etc/systemd/system/${MYSQLD_SERVICE_FILE}\"" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "rm \"/etc/systemd/system/${MYSQLD_SERVICE_FILE}\"" >> ${logdir}/main.log + + rm "/etc/systemd/system/${MYSQLD_SERVICE_FILE}" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Kann existierendes Initskript nicht entfernen." + fi + + echononl "Reload Systemd Daemon" + echo "" >> ${logdir}/main.log + echo "## - Reload Systemd Daemon" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "systemctl daemon-reload" >> ${logdir}/main.log + + systemctl daemon-reload >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Kann Systemd Daemon nicht reloaden." + fi + + + fi + +fi # if ! $PARALLEL_INSTALLATION ; then + + +## ----- +## - Install needed debian packages +## ----- + +if ! $UPDATE_MYSQL && ! $PARALLEL_INSTALLATION ; then + + echo "" + echo "" + echo -e "\033[37m\033[1mInstall needed debian packages\033[m" + echo "" + + echo "" >> ${logdir}/main.log + echo "" >> ${logdir}/main.log + echo "## -----" >> ${logdir}/main.log + echo "## - Install needed debian packages" >> ${logdir}/main.log + echo "## -----" >> ${logdir}/main.log + + ## - Uninstall debian mysql packages if installed + ## - + if [ "$DISTRIBUTION" = "Debian" ]; then + echononl "Deinstalliere Debian MySQL Pakete.." + _INSTALLED_MYSQL_DEB=`dpkg -l | grep mysql | grep -e "^i" | awk '{print$2}'` + INSTALLED_MYSQL_DEB= + for deb in $_INSTALLED_MYSQL_DEB ; do + [[ "$deb" =~ postfix ]] && continue + INSTALLED_MYSQL_DEB="$INSTALLED_MYSQL_DEB $deb" + done + if [ -n "$INSTALLED_MYSQL_DEB" ]; then + echo "" >> ${logdir}/main.log + echo "## - Deinstalliere Debian MySQL Pakete.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "DEBIAN_FRONTEND=noninteractive apt-get remove --purge -q -y $INSTALLED_MYSQL_DEB" >> ${logdir}/main.log + DEBIAN_FRONTEND=noninteractive apt-get remove --purge -q -y $INSTALLED_MYSQL_DEB >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal Kann MySQL Pakete nicht deinstalieren.. + fi + else + echo_skipped + fi + fi + + if [ "$DISTRIBUTION" = "Debian" ]; then + echononl "Deinstalliere Debian MariaDB Pakete.." + _INSTALLED_MARIADB_DEB=`dpkg -l | grep mariadb | grep -e "^i" | awk '{print$2}'` + INSTALLED_MARIADB_DEB= + for deb in $_INSTALLED_MARIADB_DEB ; do + INSTALLED_MARIADB_DEB="$INSTALLED_MARIADB_DEB $deb" + done + if [ -n "$INSTALLED_MARIADB_DEB" ]; then + echo "" >> ${logdir}/main.log + echo "## - Deinstalliere Debian MariaDB Pakete.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "DEBIAN_FRONTEND=noninteractive apt-get remove --purge -q -y $INSTALLED_MARIADB_DEB" >> ${logdir}/main.log + DEBIAN_FRONTEND=noninteractive apt-get remove --purge -q -y $INSTALLED_MARIADB_DEB >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal Kann MariaDB Pakete nicht deinstalieren.. + fi + else + echo_skipped + fi + fi + + if [ "$DISTRIBUTION" = "Debian" ]; then + echononl "Deinstalliere Debian Percona (MySQL) Pakete.." + _INSTALLED_PERCONA_DEB=`dpkg -l | grep percona | grep -e "^i" | awk '{print$2}'` + INSTALLED_PERCONA_DEB= + for deb in $_INSTALLED_PERCONA_DEB ; do + INSTALLED_PERCONA_DEB="$INSTALLED_PERCONA_DEB $deb" + done + if [ -n "$INSTALLED_MARIADB_DEB" ]; then + echo "" >> ${logdir}/main.log + echo "## - Deinstalliere Debian Percona (MySQL) Pakete.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "DEBIAN_FRONTEND=noninteractive apt-get remove --purge -q -y $INSTALLED_PERCONA_DEB" >> ${logdir}/main.log + DEBIAN_FRONTEND=noninteractive apt-get remove --purge -q -y $INSTALLED_PERCONA_DEB >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal "Kann Percona (MySQL) Pakete nicht deinstalieren.." + fi + else + echo_skipped + fi + fi + + if [ "$DISTRIBUTION" = "Debian" ]; then + echononl "Run 'apt-get autoremove'.." + echo "" >> ${logdir}/main.log + echo "## - Run 'apt-get autoremove.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "DEBIAN_FRONTEND=noninteractive apt-get -q -y autoremove" >> ${logdir}/main.log + DEBIAN_FRONTEND=noninteractive apt-get -q -y autoremove >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Running 'apt-get autoremove' failed!" + fi + fi + + # - Install Percona apt repository + # - + _failed=false + echononl "Install Percona apt repository .." + if [[ "$MYSQL_DISTRIBUTION" = "Percona" ]] ; then + echo "" >> ${logdir}/main.log + echo "## - Install Percona apt repository .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "wget -O /tmp/percona-release_0.1-5.$(lsb_release -sc)_all.deb https://repo.percona.com/apt/percona-release_0.1-5.$(lsb_release -sc)_all.deb" >> ${logdir}/main.log + wget -O /tmp/percona-release_0.1-5.$(lsb_release -sc)_all.deb https://repo.percona.com/apt/percona-release_0.1-5.$(lsb_release -sc)_all.deb >> ${logdir}/main.log 2>&1 + if [[ $? -ne 0 ]]; then + _failed=true + fi + echo "dpkg -i /tmp/percona-release_0.1-5.$(lsb_release -sc)_all.deb" >> ${logdir}/main.log 2>&1 + dpkg -i /tmp/percona-release_0.1-5.$(lsb_release -sc)_all.deb >> ${logdir}/main.log 2>&1 + if [[ $? -ne 0 ]]; then + _failed=true + fi + if $_failed ; then + echo_failed + install_additional_debian_packages=false + error "Install Percona apt repository failed!" + else + echo_ok + fi + else + echo_skipped + fi + + +# if [[ -d /etc/mysql ]]; then +# +# echononl "Sichere/Verschiebe exitierendes Verzeichnis /etc/mysql .." +# echo "" >> ${logdir}/main.log +# echo "## - Sichere/Verschiebe exitierendes Verzeichnis /etc/mysql" >> ${logdir}/main.log +# echo "## -" >> ${logdir}/main.log +# echo "mv /etc/mysql \"/etc/mysql.${_backup_date}\"" >> ${logdir}/main.log +# mv /etc/mysql "/etc/mysql.${_backup_date}" >> ${logdir}/main.log +# if [[ $? -eq 0 ]]; then +# echo_ok +# else +# echo_failed +# fatal "Kann Verzeichnis '/etc/mysql' nicht sichern!" +# fi +# +# fi # if [[ -d /etc/mysql ]]; then + + + echononl "Update index files of the debian repositories" + echo "" >> ${logdir}/main.log + echo "## - Update index files of the debian repositories" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## - See: ${logdir}/apt-install.log" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "apt-get update" >> ${logdir}/main.log + + echo "apt-get update" >> ${logdir}/apt-install.log + apt-get update >> ${logdir}/apt-install.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + echo "" >> ${logdir}/apt-install.log + else + echo_failed + fatal "\"apt-get update\" failed!" + fi + + + ## - Install cmake if not exists + ## + echononl "Installing \"cmake\".." + _cmake=`which cmake` + if [ "X$_cmake" = "X" ]; then + echo "" >> ${logdir}/main.log + echo "## - Installing \"cmake\"" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## - See: ${logdir}/apt-install.log" >> ${logdir}/main.log + echo "DEBIAN_FRONTEND=noninteractive apt-get install -q -y cmake" >> ${logdir}/main.log + + echo "DEBIAN_FRONTEND=noninteractive apt-get install -q -y cmake" >> ${logdir}/apt-install.log + DEBIAN_FRONTEND=noninteractive apt-get install -q -y cmake >> ${logdir}/apt-install.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + echo "" >> ${logdir}/apt-install.log + else + echo_failed + fatal Kann \"cmake\" nicht installieren.. + fi + else + echo_skipped + fi + + ## - Install further debian packages + ## - + declare -a deb_package_arr + for _debian_pkg in $_required_debian_packages ; do + deb_package_arr+=("$_debian_pkg") + done + + if $install_additional_debian_packages ; then + + if [[ "$MYSQL_DISTRIBUTION" = "MySQL" ]] ; then + for _debian_pkg in $_additional_debian_packages_mysql ; do + deb_package_arr+=("$_debian_pkg") + done + fi + + if [[ "$MYSQL_DISTRIBUTION" = "Percona" ]] ; then + for _debian_pkg in $_additional_debian_packages_percona ; do + deb_package_arr+=("$_debian_pkg") + done + fi + + if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] ; then + for _debian_pkg in $_additional_debian_packages_mariadb ; do + deb_package_arr+=("$_debian_pkg") + done + fi + + fi + + # - If postfix is installed, also postfix-mysql should be installed + # + if $(dpkg -l postfix 2> /devnull | grep -q -E "^ii\s+postfix\s+" 2>/dev/null) ; then + if ! $(dpkg -l postfix-mysql 2> /devnull | grep -q -E "^ii\s+postfix-mysql\s+" 2>/dev/null) ; then + deb_package_arr+=("$_debian_pkg") + fi + fi + + for _debian_pkg in ${deb_package_arr[@]} ; do + + echononl "Installing $_debian_pkg .." + if ! dpkg -l $_debian_pkg 2> /dev/null | grep -e "^ii" > /dev/null 2>&1 ; then + echo "" >> ${logdir}/main.log + echo "## - Installing $_debian_pkg" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## - See: ${logdir}/apt-install.log" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "DEBIAN_FRONTEND=noninteractive apt-get install -q -y $_debian_pkg" >> ${logdir}/main.log + + echo "" >> ${logdir}/apt-install.log + echo "DEBIAN_FRONTEND=noninteractive apt-get install -q -y $_debian_pkg" >> ${logdir}/apt-install.log + + DEBIAN_FRONTEND=noninteractive apt-get install -q -y $_debian_pkg >> ${_logdir}/debian-install.log 2>&1 + if [ "$?" = 0 ]; then + echo_ok + echo "" >> ${logdir}/apt-install.log + else + echo_failed + fatal "Installing debian package \"$_debian_pkg\" failed!" + fi + else + echo_skipped + fi + done + + if ! grep -q -E "export\s*JAVA_HOME" /etc/profile.d/* > /dev/null 2>&1 ; then + echo "export JAVA_HOME=/usr/lib/jvm/default-java" >> /etc/profile.d/java.sh + export JAVA_HOME=/usr/lib/jvm/default-java + fi + + if [[ "$os_dist" = "debian" ]] && [[ $os_version -lt 10 ]] ; then + _mysql_server_pkg="mysql-server" + else + _mysql_server_pkg="default-mysql-server" + fi + ## - Install dependency packages for \"mysql-server\" + ## - + echononl "Installing dependency packages for \"$_mysql_server_pkg\"" + echo "" >> ${logdir}/main.log + echo "## - Installing dependency packages for \"$_mysql_server_pkg\"" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## - See: ${logdir}/apt-install.log" >> ${logdir}/main.log + echo "## - " >> ${logdir}/main.log + echo "DEBIAN_FRONTEND=noninteractive apt-get -q -y build-dep $_mysql_server_pkg" >> ${logdir}/main.log + + echo "" >> ${logdir}/apt-install.log + echo "DEBIAN_FRONTEND=noninteractive apt-get -q -y build-dep $_mysql_server_pkg" >> ${logdir}/apt-install.log 2>&1 + + DEBIAN_FRONTEND=noninteractive apt-get -q -y build-dep $_mysql_server_pkg >> ${logdir}/apt-install.log 2>&1 + if [ "$?" = 0 ]; then + echo_ok + echo "" >> ${logdir}/apt-install.log + else + echo_failed + fatal "Installing dependency packages for \"$_mysql_server_pkg\" failed!" + fi + + if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] ; then + ## - Install dependency packages for \"mariadb-server\" + ## - + echononl "Installing dependency packages for \"mariadb-server\"" + echo "" >> ${logdir}/main.log + echo "## - Installing dependency packages for \"mariadb-server\"" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## - See: ${logdir}/apt-install.log" >> ${logdir}/main.log + echo "## - " >> ${logdir}/main.log + echo "DEBIAN_FRONTEND=noninteractive apt-get -q -y build-dep mariadb-server" >> ${logdir}/main.log + + echo "" >> ${logdir}/apt-install.log + echo "DEBIAN_FRONTEND=noninteractive apt-get -q -y build-dep mariadb-server" >> ${logdir}/apt-install.log 2>&1 + + DEBIAN_FRONTEND=noninteractive apt-get -q -y build-dep mariadb-server >> ${logdir}/apt-install.log 2>&1 + if [ "$?" = 0 ]; then + echo_ok + echo "" >> ${logdir}/apt-install.log + else + echo_failed + fatal "Installing dependency packages for \"mariadb-server\" failed!" + fi + fi + +# if apt-cache search mariadb-server | grep -q -E "^mariadb-server" > /dev/null 2>&1 ; then +# echononl "Installing dependency packages for \"mariadb-server\"" +# echo "DEBIAN_FRONTEND=noninteractive apt-get -q -y build-dep mariadb-server" >> ${logdir}/apt-install.log 2>&1 +# +# DEBIAN_FRONTEND=noninteractive apt-get -q -y build-dep mariadb-server >> ${logdir}/apt-install.log 2>&1 +# if [ "$?" = 0 ]; then +# echo_ok +# echo "" >> ${logdir}/apt-install.log +# else +# echo_failed +# fatal "Installing dependency packages for \"mariadb-server\" failed!" +# fi +# fi + +fi # if ! $UPDATE_MYSQL + + +## ----- +## - Backup directories and files from existing installation +## ----- + +if $UPDATE_MYSQL ; then + + echo "" + echo "" + echo -e "\033[37m\033[1mBackup directories and files from existing installation\033[m" + echo "" + + echo "" >> ${logdir}/main.log + echo "" >> ${logdir}/main.log + echo "## -----" >> ${logdir}/main.log + echo "## - Backup directories and files from existing installation" >> ${logdir}/main.log + echo "## -----" >> ${logdir}/main.log + + if [ -d $MYSQL_DATA_DIR ]; then + echononl "Sichere exitierendes MySQL Datenbank-Verzeichnis ..." + echo "" >> ${logdir}/main.log + echo "## - Sichere exitierendes MySQL Datenbank-Verzeichnis" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "cp -a $MYSQL_DATA_DIR ${MYSQL_DATA_DIR}.${_backup_date}" >> ${logdir}/main.log + cp -a $MYSQL_DATA_DIR ${MYSQL_DATA_DIR}.$_backup_date >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal "Kann Datenbank-Verzeichnis \"${MYSQL_DATA_DIR}\" nicht verschieben.." + fi + elif [[ -d "$MYSQL_CUR_DATA_DIR" ]] ; then + echononl "Kopiere exitierendes MySQL Datenbank-Verzeichnis ..." + echo "" >> ${logdir}/main.log + echo "## - Kopiere exitierendes MySQL Datenbank-Verzeichnis" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "cp -a \"$MYSQL_CUR_DATA_DIR\" \"$MYSQL_DATA_DIR\"" >> ${logdir}/main.log + cp -a "$MYSQL_CUR_DATA_DIR" "$MYSQL_DATA_DIR" >> ${logdir}/main.log + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal "Kopieren \"$MYSQL_CUR_DATA_DIR\" --> \"${MYSQL_DATA_DIR}\" fehlgeschlagen.." + fi + else + echo_failed + fatal "Exitierendes MySQL Datenbank-Verzeichnis nicht gefunden!" + fi + + + if [ -d ${MYSQL_INSTALL_DIR} ];then + echononl "Verschiebe exitierendes Installationsverzeichnis ..." + echo "" >> ${logdir}/main.log + echo "## - Verschiebe exitierendes Installationsverzeichnis" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mv $MYSQL_INSTALL_DIR $MYSQL_INSTALL_DIR.${_backup_date}" >> ${logdir}/main.log + mv $MYSQL_INSTALL_DIR $MYSQL_INSTALL_DIR.$_backup_date >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal Kann Installationsverzeichnis \"${MYSQL_INSTALL_DIR}\" nicht verschieben.. + fi + fi + +fi # if $UPDATE_MYSQL + + +## ----- +## - Create needed directories for the new installation +## ----- + +echo "" +echo "" +echo -e "\033[37m\033[1mCreate needed directories for the new installation\033[m" +echo "" + +if ! $UPDATE_MYSQL ; then + if [ -d ${MYSQL_DATA_DIR} ];then + echononl "Verschiebe exitierendes MySQL Datenverzeichnis ..." + echo "" >> ${logdir}/main.log + echo "## - Verschiebe exitierendes MySQL Datenverzeichnis" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mv $MYSQL_DATA_DIR $MYSQL_DATA_DIR.${_backup_date}" >> ${logdir}/main.log + mv $MYSQL_DATA_DIR $MYSQL_DATA_DIR.$_backup_date >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + warn "Something went wrong, because the moved directory should NOT exists at this time. + Maybe you run an fresh new installion but MySQL was already installed. anyway.." + else + echo_failed + fatal Kann MySQL Datenverzeichnis \"${MYSQL_DATA_DIR}\" nicht verschieben.. + fi + fi +fi + +echo "" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log +echo "## - Create needed directories for the new installation" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log + +echononl "Erstelle Datenbank-Verzeichnis \"$MYSQL_DATA_DIR\".." +echo "" >> ${logdir}/main.log +echo "## - Erstelle Datenbank-Verzeichnis \"$MYSQL_DATA_DIR\"" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "mkdir -p $MYSQL_DATA_DIR" >> ${logdir}/main.log +mkdir -p $MYSQL_DATA_DIR >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal Kann Datenbank-Verzeichnis \"${MYSQL_DATA_DIR}\" nicht erstellen.. +fi + + +echononl "Setze Besitzer \"${MYSQL_USER}:${MYSQL_GROUP}\" für Datenbank-Verzeichnis" +echo "" >> ${logdir}/main.log +echo "## - Setze Besitzer \"${MYSQL_USER}:${MYSQL_GROUP}\" für Datenbank-Verzeichnis" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "chown -R ${MYSQL_USER}:${MYSQL_GROUP} ${MYSQL_DATA_DIR}" >> ${logdir}/main.log +chown -R ${MYSQL_USER}:${MYSQL_GROUP} ${MYSQL_DATA_DIR} >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal Kann Besitzer für Datenbank-Verzeichnis \"${MYSQL_DATA_DIR}\" nicht ändern.. +fi + +echononl "Setze Verzeichnisrechte \"700\" für Datenbank-Verzeichnis" +echo "" >> ${logdir}/main.log +echo "## - Setze Verzeichnisrechte \"700\" für Datenbank-Verzeichnis" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "chmod 700 ${MYSQL_DATA_DIR}" >> ${logdir}/main.log +chmod 700 ${MYSQL_DATA_DIR} >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal Kann Verzeichnisrechte für Datenbank-Verzeichnis \"${MYSQL_DATA_DIR}\" nicht ändern.. +fi + + +echononl "Erstelle LOG Verzeichnis \"$MYSQL_LOG_DIR\".." +echo "" >> ${logdir}/main.log +echo "## - Erstelle LOG Verzeichnis \"$MYSQL_LOG_DIR\"" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "mkdir -p $MYSQL_LOG_DIR" >> ${logdir}/main.log +mkdir -p $MYSQL_LOG_DIR >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal Kann LOG Verzeichnis \"${MYSQL_LOG_DIR}\" nicht erstellen.. +fi + +echononl "Erstelle Error Log Datei '$_mysql_error_log'.." +echo "" >> ${logdir}/main.log +echo "## - Erstelle Error Log Datei '$_mysql_error_log'.." >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "touch $_mysql_error_log" >> ${logdir}/main.log +touch "$_mysql_error_log" >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal "Kann LOG Datei \"${_mysql_error_log}\" nicht erstellen.." +fi + +echononl "Setze Besitzer \"${MYSQL_USER}:${MYSQL_GROUP}\" für LOG Verzeichnis" +echo "" >> ${logdir}/main.log +echo "## - Setze Besitzer \"${MYSQL_USER}:${MYSQL_GROUP}\" für LOG Verzeichnis" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "chown -R ${MYSQL_USER}:${MYSQL_GROUP} ${MYSQL_LOG_DIR}" >> ${logdir}/main.log +chown -R ${MYSQL_USER}:${MYSQL_GROUP} ${MYSQL_LOG_DIR} >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal Kann Besitzer für LOG Verzeichnis \"${MYSQL_LOG_DIR}\" nicht ändern.. +fi + +echononl "Setze Verzeichnisrechte \"2750\" für LOG Verzeichnis" +echo "" >> ${logdir}/main.log +echo "## - Setze Verzeichnisrechte \"2750\" für LOG Verzeichnis" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "chmod 2750 ${MYSQL_LOG_DIR}" >> ${logdir}/main.log +chmod 2750 ${MYSQL_LOG_DIR} >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal Kann Verzeichnisrechte für LOG Verzeichnis \"${MYSQL_LOG_DIR}\" nicht ändern.. +fi + +echononl "Setze Verzeichnisrechte \"660\" für Error LOG Datei" +echo "" >> ${logdir}/main.log +echo "## - Setze Verzeichnisrechte \"660\" für Error LOG Verzeichnis" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "chmod 660 ${_mysql_error_log}" >> ${logdir}/main.log +chmod 660 ${_mysql_error_log} >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal "Kann Verzeichnisrechte für Erro LOG Datei \"${_mysql_error_log}\" nicht ändern!" +fi + + +if [ -d "${MYSQL_SRC_DIR}" ];then + echononl "Verschiebe exitierendes Sourceverzeichnis ..." + echo "" >> ${logdir}/main.log + echo "## - Verschiebe exitierendes Sourceverzeichnis" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mv ${MYSQL_SRC_DIR} ${MYSQL_SRC_DIR}.${_backup_date}" >> ${logdir}/main.log + mv ${MYSQL_SRC_DIR} ${MYSQL_SRC_DIR}.$_backup_date >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal Kann Sourceverzeichnis \"${MYSQL_SRC_DIR}\" nicht verschieben.. + fi +fi + +if $INSTALL_SYSTEMD_SERVICE ; then + + if [[ -n "$MYSQL_RUN_DIR" ]] ; then + + if [[ ! -d "$MYSQL_RUN_DIR" ]] ; then + echononl "Create Run directory '$MYSQL_RUN_DIR' .." + echo "" >> ${logdir}/main.log + echo "## - Create Run directory '$MYSQL_RUN_DIR'" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mkdir \"$MYSQL_RUN_DIR\"" >> ${logdir}/main.log + + mkdir "$MYSQL_RUN_DIR" >> ${logdir}/main.log 2>&1 + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "Creating Run directory '$MYSQL_RUN_DIR' failed!" + fi + + echononl "Change owner of run directory '$MYSQL_RUN_DIR'" + echo "" >> ${logdir}/main.log + echo "## - Change owner of run directory '$MYSQL_RUN_DIR'" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "chown $MYSQL_USER:${MYSQL_GROUP} \"${MYSQL_RUN_DIR}\"" >> ${logdir}/main.log + + chown $MYSQL_USER:${MYSQL_GROUP} ${MYSQL_RUN_DIR} >> ${logdir}/main.log + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "Changing owner of un directory '$MYSQL_RUN_DIR' failed!" + fi + + echononl "Force systemd to create run directory on each startup.." + echo "" >> ${logdir}/main.log + echo "## - Force systemd to create run directory on each startup." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## - Create '/etc/tmpfiles.d/mysql.conf' with content:" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## - # systemd tmpfile settings for mysql or mariadb" >> ${logdir}/main.log + echo "## - d $MYSQL_RUN_DIR 0755 $MYSQL_USER $MYSQL_GROUP -" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "" >> ${logdir}/main.log + echo "cat << EOF > /etc/tmpfiles.d/mysqld.conf +# systemd tmpfile settings for mysql or mariadb +d $MYSQL_RUN_DIR 0755 $MYSQL_USER $MYSQL_GROUP - +EOF" >> ${logdir}/main.log + cat < /etc/tmpfiles.d/mysqld.conf +# systemd tmpfile settings for mysql or mariadb +d $MYSQL_RUN_DIR 0755 $MYSQL_USER $MYSQL_GROUP - +EOF + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "Creating file '/etc/tmpfiles.d/mysqld.conf' failed!" + fi + fi + + fi +fi + + +## ----- +## - Basis Installation MySQL +## ----- + +echo "" +echo "" +echo -e "\033[37m\033[1mBasis Installation $MYSQL_DISTRIBUTION $MYSQL_VERSION\033[m" +echo "" + +echo "" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log +echo "## - Basis Installation $MYSQL_DISTRIBUTION $MYSQL_VERSION" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log + +## - This step is redundant and should never bee happend. +## - +if [ -d ${MYSQL_INSTALL_DIR} ];then + echononl "Verschiebe exitierendes Installationsverzeichnis ..." + echo "" >> ${logdir}/main.log + echo "## - Verschiebe exitierendes Installationsverzeichnis" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mv $MYSQL_INSTALL_DIR $MYSQL_INSTALL_DIR.${_backup_date}" >> ${logdir}/main.log + mv $MYSQL_INSTALL_DIR $MYSQL_INSTALL_DIR.$_backup_date >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + warn "Something went wrong, because the moved directory should NOT exists at this time. + Maybe you run an fresh new installion but MySQL was already installed. anyway.." + else + echo_failed + fatal Kann Installationsverzeichnis \"${MYSQL_INSTALL_DIR}\" nicht verschieben.. + fi +fi + + +echononl "Entpacke $distfile ..." +echo_wait +echo "" >> ${logdir}/main.log +echo "## - Entpacke $distfile" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "gunzip < \"${MYSQL_SRC_BASE_DIR}/$distfile\" | tar -C \"$MYSQL_SRC_BASE_DIR\" -xf -" >> ${logdir}/main.log + +gunzip < "${MYSQL_SRC_BASE_DIR}/$distfile" | tar -C "$MYSQL_SRC_BASE_DIR" -xf - +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal Kann MySQL Sourcearchiv \"${distfile}\" nicht entpacken.. +fi + +echononl "Erstelle Verzeichnis für 'Out-of source build'.." +mkdir "${MYSQL_SRC_DIR}/build-${_backup_date}" >> ${logdir}/main.log +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal Kann Verzeichnis \"build-${_backup_date}\" nicht erstellen.. +fi + + +echononl "Wechsle in das Verzeichnis '${MYSQL_SRC_DIR}/build-${_backup_date}'.." +echo "" >> ${logdir}/main.log +echo "## - Wechsle in das Verzeichnis '${MYSQL_SRC_DIR}/build-${_backup_date}'" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "cd ${MYSQL_SRC_DIR}" >> ${logdir}/main.log +cd "${MYSQL_SRC_DIR}/build-${_backup_date}" >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal "Kann nicht in das Sourceverzeicnis '${MYSQL_SRC_DIR}/build-${_backup_date}' wechseln!" +fi + + +# Prevent cmake from downloading 'boost' archive, if it is already +# present. +# +# if cmake finds the apropriate 'boost' archive in the installation directory +# cmake wil take this one. +# +if [[ "${MYSQL_DISTRIBUTION,,}" = "mysql" ]] ; then + + BOOST_ARCHIV="$(grep "SET(BOOST_PACKAGE_NAME" ${MYSQL_SRC_DIR}/cmake/boost.cmake \ + | grep -o -w -E "boost_[0-9]{1,2}_[0-9]{1,2}_[0-9]{1,2}").tar.gz" + + BOOST_VERSION="$(echo $BOOST_ARCHIV | grep -o -E "[0-9]{1,2}_[0-9]{1,2}_[0-9]{1,2}" | tr "_" "\." )" + + if [[ -f "${MYSQL_SRC_BASE_DIR}/$BOOST_ARCHIV" ]] ; then + + echononl "Erstelle Installations Verzeichnis '$(basename $MYSQL_INSTALL_DIR)'.." + echo "" >> ${logdir}/main.log + echo "## - Erstelle Installations Verzeichnis '$(basename $MYSQL_INSTALL_DIR)'" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mkdir $MYSQL_INSTALL_DIR" >> ${logdir}/main.log + mkdir "$MYSQL_INSTALL_DIR" >> ${logdir}/main.log 2>&1 + if [[ $? -ne 0 ]] ; then + echo_failed + + error Erstellen des Installations Verzeichnisses $MYSQL_INSTALL_DIR ist fehlgeschlagen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + else + echo_ok + fi + + echononl "Kopiere '$BOOST_ARCHIV' nach '$(basename $MYSQL_INSTALL_DIR)'.." + echo "" >> ${logdir}/main.log + echo "## - Kopiere '$BOOST_ARCHIV' nach '$(basename $MYSQL_INSTALL_DIR)'.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "cp \"${MYSQL_SRC_BASE_DIR}/$BOOST_ARCHIV\" \"$MYSQL_INSTALL_DIR)\"" >> ${logdir}/main.log + cp "${MYSQL_SRC_BASE_DIR}/$BOOST_ARCHIV" "$MYSQL_INSTALL_DIR" >> ${logdir}/main.log 2>&1 + if [[ $? -ne 0 ]] ; then + echo_failed + + error "Kann '$BOOST_ARCHIV' nicht in das Installations Verzeichniss '$MYSQL_INSTALL_DIR' kopieren.." + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + else + echo_ok + fi + + fi + +fi + + +# - Erstelle Optionen für 'cmake' +# - +# --- +# - MySQL / Percona +# --- +# - Note: +# - +# - Since MySQL v 5.7.16 the default 'secure_file_priv' value has changed +# - +# - NULL (>= MySQL 5.7.16), empty (< MySQL 5.7.16) +# - +# - We change the default to empty ("") with -D INSTALL_SECURE_FILE_PRIVDIR="" option +# - +# --- +# - MariaDB +# --- +# - +# - NOT supported (in contrast to original MySQL) +# - +# - -DINSTALL_SECURE_FILE_PRIVDIR=\"\" +# - -DDOWNLOAD_BOOST=1 +# - -DWITH_BOOST=$MYSQL_INSTALL_DIR +# - +# - -DSYSTEMD_PID_DIR=$SYSTEMD_PID_DIR" +# - +# - +# - Options enabled (not availabe at original MySQL) +# - +# - configured exactly as the binary releases from MariaDB +# - -DBUILD_CONFIG=mysql_release +# - creates libmysql* symbolic links: +# - -CONC_WITH_MYSQLCOMPAT=ON +# - groonga log file path +# - -GRN_LOG_PATH=${MYSQL_LOG_DIR}/groonga.log +# - +# - +# - To get a complete list of available options, type +# - shell> cmake . -LH | tee ~/mysql_cmake_options.txt +# - +echononl "Erstelle Optionen für 'cmake'" +echo "" >> ${logdir}/main.log +echo "## - Erstelle Optionen für 'cmake'" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log + +if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]]; then + + cmake_options=" + .. + -DBUILD_CONFIG=mysql_release + -DCMAKE_INSTALL_PREFIX=$MYSQL_INSTALL_DIR + -DMYSQL_DATADIR=$MYSQL_DATA_DIR + -DMYSQL_UNIX_ADDR=$MYSQL_UNIX_SOCKET + -DENABLED_LOCAL_INFILE=ON + -DGRN_LOG_PATH=$mariadb_groonga_log + -DCONC_WITH_MYSQLCOMPAT=ON + -DDEFAULT_CHARSET=utf8 + -DDEFAULT_COLLATION=utf8_general_ci + -DWITH_SSL=/usr/local/openssl-1.1.1" + + if $INSTALL_SYSTEMD_SERVICE ; then + cmake_options="$cmake_options + -DWITH_SYSTEMD=yes" + fi + + # Fix error: static jemalloc_pic.a can only be used up to jemalloc 4 + # + if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 9 ]] ; then + cmake_options="$cmake_options + -DWITH_JEMALLOC=OFF" + fi + +else + + cmake_options=" + .. + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DBUILD_CONFIG=mysql_release + -DCMAKE_INSTALL_PREFIX=$MYSQL_INSTALL_DIR + -DMYSQL_DATADIR=$MYSQL_DATA_DIR + -DMYSQL_UNIX_ADDR=$MYSQL_UNIX_SOCKET + -DINSTALL_SECURE_FILE_PRIVDIR=\"\" + -DENABLED_LOCAL_INFILE=1 + -DDOWNLOAD_BOOST=1 + -DWITH_BOOST=$MYSQL_INSTALL_DIR + -DDEFAULT_CHARSET=utf8 + -DDEFAULT_COLLATION=utf8_general_ci + -DWITH_SSL=/usr/local/openssl-1.1.1 +" + + if $INSTALL_SYSTEMD_SERVICE ; then + cmake_options="$cmake_options -DWITH_SYSTEMD=1 + -DSYSTEMD_PID_DIR=$SYSTEMD_PID_DIR" + fi + +fi +echo "cmake_options=\"$cmake_options\"" >> ${logdir}/main.log +echo_ok + +echononl "Konfiguriere MySQL (cmake).." +echo_wait +echo "" >> ${logdir}/main.log +echo "# - Konfiguriere MySQL (cmake).." >> ${logdir}/main.log +echo "# -" >> ${logdir}/main.log +echo "# - See ${logdir}/cmake-conf.log" >> ${logdir}/main.log +echo "# -" >> ${logdir}/main.log +echo "cmake \$cmake_options " >> ${logdir}/main.log +cmake $cmake_options > ${logdir}/cmake-conf.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + + if [[ "${MYSQL_DISTRIBUTION,,}" = "mysql" ]] \ + && $(grep "\-\- Download failed" ${logdir}/cmake-conf.log > /dev/null 2>&1) ; then + + error "It seems downloading $BOOST_ARCHIV failed." + + echononl "Try to download '$BOOST_ARCHIV' directly.." + echo "" >> ${logdir}/main.log + echo "# - Try to download '$BOOST_ARCHIV' directly.." >> ${logdir}/main.log + echo "# -" >> ${logdir}/main.log + echo "wget -O \"${MYSQL_SRC_BASE_DIR}/$BOOST_ARCHIV\" \\" >> ${logdir}/main.log + echo " https://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/${BOOST_ARCHIV}" >> ${logdir}/main.log + + wget -O "${MYSQL_SRC_BASE_DIR}/$BOOST_ARCHIV" \ + https://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/${BOOST_ARCHIV} >> ${logdir}/main.log 2>&1 + if [[ $? -eq 0 ]]; then + + echo_ok + + echononl "Erstelle Installations Verzeichnis '$(basename $MYSQL_INSTALL_DIR)'.." + if [[ -d "$MYSQL_INSTALL_DIR" ]]; then + echo_skipped + else + echo "" >> ${logdir}/main.log + echo "## - Erstelle Installations Verzeichnis '$(basename $MYSQL_INSTALL_DIR)'" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mkdir $MYSQL_INSTALL_DIR" >> ${logdir}/main.log + mkdir "$MYSQL_INSTALL_DIR" >> ${logdir}/main.log 2>&1 + if [[ $? -ne 0 ]] ; then + echo_failed + + error Erstellen des Installations Verzeichnisses $MYSQL_INSTALL_DIR ist fehlgeschlagen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + else + echo_ok + fi + fi + + echononl "Kopiere '$BOOST_ARCHIV' nach '$(basename $MYSQL_INSTALL_DIR)'.." + echo "" >> ${logdir}/main.log + echo "## - Kopiere '$BOOST_ARCHIV' nach '$(basename $MYSQL_INSTALL_DIR)'.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "cp \"${MYSQL_SRC_BASE_DIR}/$BOOST_ARCHIV\" \"$MYSQL_INSTALL_DIR)\"" >> ${logdir}/main.log + cp "${MYSQL_SRC_BASE_DIR}/$BOOST_ARCHIV" "$MYSQL_INSTALL_DIR" >> ${logdir}/main.log 2>&1 + if [[ $? -ne 0 ]] ; then + echo_failed + + error "Kann '$BOOST_ARCHIV' nicht in das Installations Verzeichniss '$MYSQL_INSTALL_DIR' kopieren.." + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + else + echo_ok + fi + + echononl "Nochmal: konfiguriere MySQL (cmake).." + echo_wait + echo "" >> ${logdir}/main.log + echo "# - Nochml: konfiguriere MySQL (cmake).." >> ${logdir}/main.log + echo "# -" >> ${logdir}/main.log + echo "# - See ${logdir}/cmake-conf.log" >> ${logdir}/main.log + echo "# -" >> ${logdir}/main.log + echo "cmake \$cmake_options " >> ${logdir}/main.log + cmake $cmake_options > ${logdir}/cmake-conf.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + echo "" + else + echo_failed + rm -rf "${MYSQL_SRC_BASE_DIR}/$BOOST_ARCHIV" + fatal Konfiguration erneut fehlgeschlagen. Siehe ${logdir}/cmake-conf.log .. + fi + + else + echo_failed + fatal "Downloading '$BOOST_ARCHIV' directly failed" + fi + + else + fatal Konfiguration fehlgeschlagen. Siehe ${logdir}/cmake-conf.log .. + fi +fi + +echononl "Kompiliere MySQL.." +echo_wait +echo "" >> ${logdir}/main.log +echo "## - Kompiliere MySQL" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "## - See: ${logdir}/make.log" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "make" >> ${logdir}/main.log +make > ${logdir}/make.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal Kompilieren der MySQL Sourcen ist fehlgeschlagen. Siehe ${logdir}/make.log .. +fi + +echononl "Installiere MySQL.." +echo_wait +echo "" >> ${logdir}/main.log +echo "## - Installiere MySQL" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "## - See: ${logdir}/make_install.log" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "make install" >> ${logdir}/main.log +make install > ${logdir}/make_install.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal Installieren von MySQL ist fehlgeschlagen. Siehe ${logdir}/make_install.log .. +fi + + +## ----- +## - Einbinden der MySQL Installation in das System +## ----- + +echo "" +echo "" +echo -e "\033[37m\033[1mEinbinden der $MYSQL_DISTRIBUTION $MYSQL_VERSION Installation in das System\033[m" +echo "" + +echo "" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log +echo "## - Einbinden der $MYSQL_DISTRIBUTION $MYSQL_VERSION Installation in das System" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log + +echononl "Konfiguriere Manpages.." +_done=false +if [ -f /etc/manpath.config ];then + if ! grep /usr/local/mysql/man /etc/manpath.config > /dev/null 2<&1 ; then + echo "## - Konfiguriere Manpages" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## - Fuege folgend Zeilen am Ende der Datei \"/etc/manpath.config\" hinzu:" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## - MANDATORY_MANPATH /usr/local/mysql/man /var/cache/man" >> ${logdir}/main.log + echo "## - MANPATH_MAP /usr/local/mysql/bin /usr/local/mysql/man" >> ${logdir}/main.log + echo "## - MANPATH_MAP /usr/local/mysql/bin /usr/local/mysql/man" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + + echo >> /etc/manpath.config + echo "MANDATORY_MANPATH /usr/local/mysql/man /var/cache/man" >> /etc/manpath.config + echo "MANPATH_MAP /usr/local/mysql/bin /usr/local/mysql/man" >> /etc/manpath.config + echo "MANDB_MAP /usr/local/mysql/man /var/cache/man" >> /etc/manpath.config + + _done=true + fi +elif [ -f /etc/man.conf];then + if ! grep /opt/apache2/man /etc/man.conf > /dev/null 2<&1 ; then + echo "## - Konfiguriere Manpages" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## - Fuege folgend Zeilen am Ende der Datei \"/etc/man.conf\" hinzu:" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## - MANPATH /opt/mysql/man /var/cache/man" >> ${logdir}/main.log + echo "## - MANPATH_MAP /opt/mysql/bin /opt/apache2/man" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + + echo >> /etc/man.conf + echo "MANPATH /opt/mysql/man /var/cache/man" >> /etc/man.conf + echo "MANPATH_MAP /opt/mysql/bin /opt/apache2/man" >> /etc/man.conf + + _done=true + fi +fi +if $_done ; then + echo_ok +else + echo_skipped +fi + +## - Symlink Installationsverzeichnis (i.d.R. /usr/local/mysql) +## - +if $SYMLINK_INSTALL_DIR ; then + + echononl "Entferne vorhandenen Symlink `dirname $MYSQL_INSTALL_DIR`/mysql.." + if [[ -h "$(dirname $MYSQL_INSTALL_DIR)/mysql" ]]; then + echo "" >> ${logdir}/main.log + echo "## - Entferne vorhandenen Symlink `dirname $MYSQL_INSTALL_DIR`/mysql" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "rm \"$(dirname $MYSQL_INSTALL_DIR)/mysql\"" >> ${logdir}/main.log + rm "$(dirname $MYSQL_INSTALL_DIR)/mysql" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Kann Symlink `dirname $MYSQL_INSTALL_DIR`/mysql nicht entfernen.. + fi + else + echo_skipped + fi + + echononl "Verschiebe Verzeichnis '$(dirname $MYSQL_INSTALL_DIR)/mysql' ..." + if [ -d "$(dirname $MYSQL_INSTALL_DIR)/mysql" ]; then + echo "" >> ${logdir}/main.log + echo "## - Verschiebe Verzeichnis '$(dirname $MYSQL_INSTALL_DIR)/mysql'" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mv \"$(dirname $MYSQL_INSTALL_DIR)/mysql)\" \"$(dirname $MYSQL_INSTALL_DIR)/mysql.$(date +"%Y%m%d-%H%M")" \ + >> ${logdir}/main.log + mv "$(dirname $MYSQL_INSTALL_DIR)/mysql" "$(dirname $MYSQL_INSTALL_DIR)/mysql.$(date +"%Y%m%d-%H%M")" \ + >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Kann Installationsverzeichnis \"${MYSQL_INSTALL_DIR}\" nicht verschieben.. + fi + else + echo_skipped + fi + + echononl "Erstelle Symlink $(dirname $MYSQL_INSTALL_DIR)/mysql --> $MYSQL_INSTALL_DIR" + echo "" >> ${logdir}/main.log + echo "## - Erstelle Symlink $(dirname $MYSQL_INSTALL_DIR)/mysql --> $MYSQL_INSTALL_DIR" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "ln -s \"$(basename $MYSQL_INSTALL_DIR)\" \"$(dirname $MYSQL_INSTALL_DIR)/mysql\"" >> ${logdir}/main.log + ln -s "$(basename $MYSQL_INSTALL_DIR)" "$(dirname $MYSQL_INSTALL_DIR)/mysql" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Kann Symlink `basename $MYSQL_INSTALL_DIR` --> `dirname $MYSQL_INSTALL_DIR`/mysql nicht erstellen .. + fi +fi + +## - Symlink Datenverzeichnis +## - +if $SYMLINK_DATA_DIR ; then + + if [ -h "$(dirname $MYSQL_DATA_DIR)/mysql" ]; then + echononl "Entferne vorhandenen Symlink '$(dirname $MYSQL_DATA_DIR)/mysql'.." + echo "" >> ${logdir}/main.log + echo "## - Entferne vorhandenen Symlink '$(dirname $MYSQL_DATA_DIR)/mysql'" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "rm $(dirname $MYSQL_DATA_DIR)/mysql" >> ${logdir}/main.log + rm $(dirname $MYSQL_DATA_DIR)/mysql >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Kann Symlink `dirname $MYSQL_DATA_DIR`/mysql nicht entfernen.. + fi + fi + + if [ -d "$(dirname $MYSQL_DATA_DIR)/mysql" ]; then + echononl "Verschiebe Verzeichnis '$(dirname $MYSQL_DATA_DIR)/mysql' ..." + echo "" >> ${logdir}/main.log + echo "## - Verschiebe Verzeichnis '$(dirname $MYSQL_DATA_DIR)/mysql'" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mv \"$(dirname $MYSQL_DATA_DIR)/mysql\" \"$(dirname $MYSQL_DATA_DIR)/mysql.$(date +"%Y%m%d-%H%M")" \ + >> ${logdir}/main.log + mv "$(dirname $MYSQL_DATA_DIR)/mysql" "$(dirname $MYSQL_DATA_DIR)/mysql.$(date +"%Y%m%d-%H%M")" \ + >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Kann Datenverzeichnis \"${MYSQL_DATA_DIR}\" nicht verschieben.. + fi + fi + + echononl "Erstelle Symlink `dirname $MYSQL_DATA_DIR`/mysql --> $MYSQL_DATA_DIR" + echo "" >> ${logdir}/main.log + echo "## - Erstelle Symlink `dirname $MYSQL_DATA_DIR`/mysql --> $MYSQL_DATA_DIR" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "ln -s \"$(basename $MYSQL_DATA_DIR)\" \"$(dirname $MYSQL_DATA_DIR)/mysql\"" >> ${logdir}/main.log + ln -s "$(basename $MYSQL_DATA_DIR)" "$(dirname $MYSQL_DATA_DIR)/mysql" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Kann Symlink $(basename $MYSQL_DATA_DIR) --> $(dirname $MYSQL_DATA_DIR)/mysql nicht erstellen .." + fi +fi + + +_checkdir="$(dirname "$MYSQL_INSTALL_DIR")/mysql/bin" +echononl "Füge '$_checkdir' zur PATH Variable hinzu .." +if [ -f /etc/profile ]; then + if ! grep -e "$_checkdir" /etc/profile > /dev/null 2<&1 ; then + echo "" >> ${logdir}/main.log + echo "## - Füge `dirname $MYSQL_INSTALL_DIR`/mysql/bin zur PATH Variable hinzu" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s#^([ ]*export[ ]*PATH.*$)#check_dir=\$_checkdir\nif [ -d \\\"\\\\\\\$check_dir\\\" ];then\n PATH=\\\\\\\${check_dir}:\\\\\\\$PATH\nfi\n\n\1#\" /etc/profile" >> ${logdir}/main.log 2<&1 + + perl -i -n -p -e "s#^([ ]*export[ ]*PATH.*$)#check_dir=$_checkdir\nif [ -d \"\\\$check_dir\" ];then\n PATH=\\\${check_dir}:\\\$PATH\nfi\n\n\1#" /etc/profile >> ${logdir}/main.log 2<&1 + + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + if ! echo "$PATH" | grep $_checkdir >> ${logdir}/main.log 2>&1 ; then + export PATH=${_checkdir}:$PATH + fi + + else + echo_skipped + fi +else + echo_skipped +fi + + +## ----- +## - Konfiguration ( Teil 1) MySQL Installation +## ----- + +echo "" +echo "" +echo -e "\033[37m\033[1mKonfiguration (Teil 1) der $MYSQL_DISTRIBUTION $MYSQL_VERSION Installation\033[m" +echo "" + +echo "" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log +echo "## - Konfiguration (Teil 1) der $MYSQL_DISTRIBUTION $MYSQL_VERSION Installation" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log + + +echononl "Erstelle Konfigurationsdatei /etc/ld.so.conf.d/mysql.conf.." +echo "" >> ${logdir}/main.log +echo "## - Erstelle Konfigurationsdatei /etc/ld.so.conf.d/mysql.conf" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "cat << EOF >/etc/ld.so.conf.d/mysql.conf +`dirname $MYSQL_INSTALL_DIR`/mysql/lib +EOF" >> ${logdir}/main.log + +cat << EOF >/etc/ld.so.conf.d/mysql.conf +`dirname $MYSQL_INSTALL_DIR`/mysql/lib +EOF +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + error Kann Datei /etc/ld.so.conf.d/mysql.conf für dynamischen Linker nicht erstellen .. +fi + +echononl "Erstelle symbolische Links auf Libraries (ldconfig).." +echo "" >> ${logdir}/main.log +echo "## - Erstelle symbolische Links auf Libraries (ldconfig)" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "ldconfig" >> ${logdir}/main.log +ldconfig >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + error "Der Befehl \"ldconfig\" ist fehgeschlagen" +fi + +echo +echononl "Richte $MYSQL_DISTRIBUTION Systemtabellen ein.." +if ! $UPDATE_MYSQL ; then + cd $MYSQL_INSTALL_DIR + echo "" >> ${logdir}/main.log + + if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] \ + || ( [[ "$MYSQL_DISTRIBUTION" = "MySQL" ]] \ + && [[ $MYSQL_MAJOR_VERSION -eq 5 ]] \ + && [[ $MYSQL_MINOR_VERSION -le 6 ]] ); then + + echo "## - Richte $MYSQL_DISTRIBUTION Systemtabellen ein" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/scripts/mysql_install_db \ " >> ${logdir}/main.log + echo " --user=$MYSQL_USER \ " >> ${logdir}/main.log + echo " --basedir=$MYSQL_INSTALL_DIR \ " >> ${logdir}/main.log + echo " --datadir=$MYSQL_DATA_DIR \ " >> ${logdir}/main.log + echo " --lc-messages-dir=$MYSQL_INSTALL_DIR/share" >> ${logdir}/main.log + echo "" >> ${logdir}/main.log + + ${MYSQL_INSTALL_DIR}/scripts/mysql_install_db \ + --user=$MYSQL_USER \ + --basedir=$MYSQL_INSTALL_DIR \ + --datadir=$MYSQL_DATA_DIR \ + --lc-messages-dir=$MYSQL_INSTALL_DIR/share \ + >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Das Einrichten der $MYSQL_DISTRIBUTION Systemtabellen ist fehlgeschlagen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + else + + echo "## - Richte $MYSQL_DISTRIBUTION Systemtabellen ein" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysqld --initialize-insecure \ " >> ${logdir}/main.log + echo " --user=$MYSQL_USER \ " >> ${logdir}/main.log + echo " --basedir=$MYSQL_INSTALL_DIR \ " >> ${logdir}/main.log + echo " --datadir=$MYSQL_DATA_DIR \ " >> ${logdir}/main.log + echo " --lc-messages-dir=$MYSQL_INSTALL_DIR/share" >> ${logdir}/main.log + echo "" >> ${logdir}/main.log + + ${MYSQL_INSTALL_DIR}/bin/mysqld --initialize-insecure \ + --user=$MYSQL_USER \ + --basedir=$MYSQL_INSTALL_DIR \ + --datadir=$MYSQL_DATA_DIR \ + --lc-messages-dir=$MYSQL_INSTALL_DIR/share \ + >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Das Einrichten der $MYSQL_DISTRIBUTION Systemtabellen ist fehlgeschlagen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + fi +else + echo_skipped +fi + + +echononl "Create directory \"etc\".." +cd $MYSQL_INSTALL_DIR +echo "" >> ${logdir}/main.log +echo "## - Create directory \"etc\"" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "cd $MYSQL_INSTALL_DIR" >> ${logdir}/main.log +echo "mkdir ${MYSQL_INSTALL_DIR}/etc" >> ${logdir}/main.log +mkdir ${MYSQL_INSTALL_DIR}/etc >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "Change permissions (755) to directory \"etc\".." +echo "" >> ${logdir}/main.log +echo "## - Change permissions (755) to directory \"etc\"" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "chmod 755 ${MYSQL_INSTALL_DIR}/etc" >> ${logdir}/main.log +chmod 755 ${MYSQL_INSTALL_DIR}/etc >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +echononl "Create directory \"mysql-files\".." +cd $MYSQL_INSTALL_DIR +echo "" >> ${logdir}/main.log +echo "## - Create directory \"mysql-files\"" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "cd $MYSQL_INSTALL_DIR" >> ${logdir}/main.log +echo "mkdir ${MYSQL_INSTALL_DIR}/mysql-files" >> ${logdir}/main.log +mkdir ${MYSQL_INSTALL_DIR}/mysql-files >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "Change permissions (770) to directory \"mysql-files\".." +echo "" >> ${logdir}/main.log +echo "## - Change permissions (770) to directory \"mysql-files\"" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "chmod 770 ${MYSQL_INSTALL_DIR}/mysql-files" >> ${logdir}/main.log +chmod 770 ${MYSQL_INSTALL_DIR}/mysql-files >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "Change owner ($MYSQL_USER) of directory 'mysql-files'.." +echo "" >> ${logdir}/main.log +echo "## - Change owner ($MYSQL_USER) of directory 'mysql-files'" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "chown $MYSQL_USER ${MYSQL_INSTALL_DIR}/mysql-files" >> ${logdir}/main.log +chown $MYSQL_USER ${MYSQL_INSTALL_DIR}/mysql-files >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "Generate MySQL SSL Certificate and RSA Key.." +if [[ "$MYSQL_MAIN_VERSION" = "5.6" ]] ; then + echo_skipped +else + echo "" >> ${logdir}/main.log + echo "## - Generate MySQL SSL Certificate and RSA Key" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "cd $MYSQL_INSTALL_DIR" >> ${logdir}/main.log + cd $MYSQL_INSTALL_DIR + if [[ -x "${MYSQL_INSTALL_DIR}/bin/mysql_ssl_rsa_setup" ]] ; then + echo "${MYSQL_INSTALL_DIR}/bin/mysql_ssl_rsa_setup --datadir=$MYSQL_DATA_DIR .." >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql_ssl_rsa_setup --datadir=$MYSQL_DATA_DIR >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Generating MySQL SSL Certificate and RSA Key failed" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + else + echo_skipped + warn "Script for generating certificates (mysql_ssl_rsa_setup) is not supported" + fi +fi + + +echononl "Setze Besitzer/Gruppe für das Datenbankverzeichnis.." +echo "" >> ${logdir}/main.log +echo "## - Setze Besitzer/Gruppe für das Datenbankverzeichnis" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "chown -R ${MYSQL_USER}:$MYSQL_GROUP $MYSQL_DATA_DIR" >> ${logdir}/main.log +chown -R ${MYSQL_USER}:$MYSQL_GROUP $MYSQL_DATA_DIR >> ${logdir}/main.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + error Konnte Besitzer/Gruppe für das Datenbankverzeichnis $MYSQL_DATA_DIR nicht setzen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" +fi + + +_new_cnf_needed=false +if $UPDATE_MYSQL ; then + + _my_cnf_old= + if [[ "$CURRENT_VERSION" = "$MYSQL_VERSION" ]] ; then + if [[ -f "$(realpath ${MYSQL_CUR_INSTALL_DIR}).${_backup_date}/etc/my.cnf" ]]; then + _my_cnf_old="$(realpath ${MYSQL_CUR_INSTALL_DIR}).${_backup_date}/etc/my.cnf" + elif [[ -f "$(realpath ${MYSQL_CUR_INSTALL_DIR}).${_backup_date}/my.cnf" ]]; then + _my_cnf_old="$(realpath ${MYSQL_CUR_INSTALL_DIR}).${_backup_date}/my.cnf" + fi + else + if [[ -f "$(realpath ${MYSQL_CUR_INSTALL_DIR})/etc/my.cnf" ]]; then + _my_cnf_old="$(realpath ${MYSQL_CUR_INSTALL_DIR})/etc/my.cnf" + elif [[ -f "$(realpath ${MYSQL_CUR_INSTALL_DIR})/my.cnf" ]]; then + _my_cnf_old="$(realpath ${MYSQL_CUR_INSTALL_DIR})/my.cnf" + fi + fi + + echononl "Copy 'my.cnf from old installation to the new one.." + if [[ -f "$_my_cnf_old" ]] ; then + echo "" >> ${logdir}/main.log + echo "## - Copy 'my.cnf from old installation to the new one" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "cp -a \"$_my_cnf_old\" \"${MY_CNF_FILE}\"" >> ${logdir}/main.log + cp -a "$_my_cnf_old" "${MY_CNF_FILE}" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + _new_cnf_needed=true + error "Konnte Konfigurationsdatei 'my.cnf' nicht vom alten in das neue Installations Verz.kopieren.." + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + else + echo_skipped + fi + + if [[ ! -f "$MY_CNF_FILE" ]] ; then + _new_cnf_needed=true + else + + echononl "Ersetze 'socket' variable in 'my.cnf'.." + if $(grep -q -E "^\s*socket\s*=\s*${MYSQL_UNIX_SOCKET}" "$MY_CNF_FILE" 2> /dev/null) ; then + echo_skipped + else + echo "" >> ${logdir}/main.log + echo "## - Ersetze 'socket' variable in 'my.cnf'.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s#^(\s*socket\s*=).*#\1 ${MYSQL_UNIX_SOCKET}#\" \"$MY_CNF_FILE\"" >> ${logdir}/main.log + + perl -i -n -p -e "s#^(\s*socket\s*=).*#\1 ${MYSQL_UNIX_SOCKET}#" "$MY_CNF_FILE" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Ersetzen von 'socket' variable in 'my.cnf' fehlgeschlagen." + fi + + fi + + if [[ "$MYSQL_MAJOR_VERSION" -gt 5 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 5 ]] && [[ "$MYSQL_MINOR_VERSION" -ge 7 ]] ) ; then + proof_var="thread[_-]concurrency" + echononl "Deaktiviere '${proof_var} .." + if grep -q -E "^\s*${proof_var}.*" "$MY_CNF_FILE" 2> /dev/null ; then + echo "" >> ${logdir}/main.log + echo "## - Deaktiviere '${proof_var} .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s/^(\s*)(${proof_var}.*)/#\1\2/\" \"$MY_CNF_FILE\"" >> ${logdir}/main.log + perl -i -n -p -e "s/^(\s*)(${proof_var}.*)/#\1\2/" "$MY_CNF_FILE" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Konnte '${proof_var}' nicht deaktivieren." + fi + else + echo_skipped + fi + + proof_var="innodb[_-]additional[_-]mem[_-]pool[_-]size" + echononl "Deaktiviere '${proof_var} .." + if grep -q -E "^\s*${proof_var}.*" "$MY_CNF_FILE" 2> /dev/null ; then + echo "" >> ${logdir}/main.log + echo "## - Deaktiviere '${proof_var} .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s/^(\s*)(${proof_var}.*)/#\1\2/\" \"$MY_CNF_FILE\"" >> ${logdir}/main.log + perl -i -n -p -e "s/^(\s*)(${proof_var}.*)/#\1\2/" "$MY_CNF_FILE" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Konnte '${proof_var}' nicht deaktivieren." + fi + else + echo_skipped + fi + + fi # if [[ "$MYSQL_MAJOR_VERSION" -lt 5 ]] || ... + + + if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + + proof_var="sql[_-]mode" + echononl "Deaktiviere '${proof_var} .." + if grep -q -E "^\s*${proof_var}.*" "$MY_CNF_FILE" 2> /dev/null ; then + echo "" >> ${logdir}/main.log + echo "## - Deaktiviere '${proof_var} .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s/^(\s*)(${proof_var}.*)/## - Since Version 8.0.11 NO_AUTO_CREATE_USER is no longer available\n## -\n## - For now, we will use the default value, it seems to be ok.\n## -\n#\1\2/\" \"$MY_CNF_FILE\"" >> ${logdir}/main.log + perl -i -n -p -e "s/^(\s*)(${proof_var}.*)/## - Since Version 8.0.11 NO_AUTO_CREATE_USER is no longer available\n## -\n## - For now, we will use the default value, it seems to be ok.\n## -\n#\1\2/" "$MY_CNF_FILE" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Konnte '${proof_var}' nicht deaktivieren." + fi + else + echo_skipped + fi + + proof_var="query[_-]cache[_-]limit" + echononl "Deaktiviere '${proof_var} .." + if grep -q -E "^\s*${proof_var}.*" "$MY_CNF_FILE" 2> /dev/null ; then + echo "" >> ${logdir}/main.log + echo "## - Deaktiviere '${proof_var} .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s/^(\s*)(${proof_var}.*)/## - Removed since Version 8.0.3\n## -\n#\1\2/\" \"$MY_CNF_FILE\"" >> ${logdir}/main.log + perl -i -n -p -e "s/^(\s*)(${proof_var}.*)/## - Removed since Version 8.0.3\n## -\n#\1\2/" "$MY_CNF_FILE" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Konnte '${proof_var}' nicht deaktivieren." + fi + else + echo_skipped + fi + + proof_var="query[_-]cache[_-]type" + echononl "Deaktiviere '${proof_var} .." + if grep -q -E "^\s*${proof_var}.*" "$MY_CNF_FILE" 2> /dev/null ; then + echo "" >> ${logdir}/main.log + echo "## - Deaktiviere '${proof_var} .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s/^(\s*)(${proof_var}.*)/## - Removed since Version 8.0.3\n## -\n#\1\2/\" \"$MY_CNF_FILE\"" >> ${logdir}/main.log + perl -i -n -p -e "s/^(\s*)(${proof_var}.*)/## - Removed since Version 8.0.3\n## -\n#\1\2/" "$MY_CNF_FILE" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Konnte '${proof_var}' nicht deaktivieren." + fi + else + echo_skipped + fi + + proof_var="query[_-]cache[_-]min[_-]res[_-]unit" + echononl "Deaktiviere '${proof_var} .." + if grep -q -E "^\s*${proof_var}.*" "$MY_CNF_FILE" 2> /dev/null ; then + echo "" >> ${logdir}/main.log + echo "## - Deaktiviere '${proof_var} .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s/^(\s*)(${proof_var}.*)/## - Removed since Version 8.0.3\n## -\n#\1\2/\" \"$MY_CNF_FILE\"" >> ${logdir}/main.log + perl -i -n -p -e "s/^(\s*)(${proof_var}.*)/## - Removed since Version 8.0.3\n## -\n#\1\2/" "$MY_CNF_FILE" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Konnte '${proof_var}' nicht deaktivieren." + fi + else + echo_skipped + fi + + proof_var="query[_-]cache[_-]size" + echononl "Deaktiviere '${proof_var} .." + if grep -q -E "^\s*${proof_var}.*" "$MY_CNF_FILE" 2> /dev/null ; then + echo "" >> ${logdir}/main.log + echo "## - Deaktiviere '${proof_var} .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s/^(\s*)(${proof_var}.*)/## -\n## - Removed since Version 8.0.3\n## -\n#\1\2/\" \"$MY_CNF_FILE\"" >> ${logdir}/main.log + perl -i -n -p -e "s/^(\s*)(${proof_var}.*)/## -\n## - Removed since Version 8.0.3\n## -\n#\1\2/" "$MY_CNF_FILE" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Konnte '${proof_var}' nicht deaktivieren." + fi + else + echo_skipped + fi + + proof_var="innodb[_-]large[_-]prefix" + echononl "Deaktiviere '${proof_var} .." + if grep -q -E "^\s*${proof_var}.*" "$MY_CNF_FILE" 2> /dev/null ; then + echo "" >> ${logdir}/main.log + echo "## - Deaktiviere '${proof_var} .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s/^(\s*)(${proof_var}.*)/## -\n## - Removed since Version 8.0.0\n## -\n#\1\2/\" \"$MY_CNF_FILE\"" >> ${logdir}/main.log + perl -i -n -p -e "s/^(\s*)(${proof_var}.*)/## -\n## - Removed since Version 8.0.0\n## -\n#\1\2/" "$MY_CNF_FILE" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Konnte '${proof_var}' nicht deaktivieren." + fi + else + echo_skipped + fi + + proof_var="nnodb[_-]file[_-]format" + echononl "Deaktiviere '${proof_var} .." + if grep -q -E "^\s*${proof_var}.*" "$MY_CNF_FILE" 2> /dev/null ; then + echo "" >> ${logdir}/main.log + echo "## - Deaktiviere '${proof_var} .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s/^(\s*)(${proof_var}.*)/## -\n## - Removed since Version 8.0.0\n## -\n#\1\2/\" \"$MY_CNF_FILE\"" >> ${logdir}/main.log + perl -i -n -p -e "s/^(\s*)(${proof_var}.*)/## -\n## - Removed since Version 8.0.0\n## -\n#\1\2/" "$MY_CNF_FILE" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Konnte '${proof_var}' nicht deaktivieren." + fi + else + echo_skipped + fi + + fi # if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] || .. + + fi +fi + +if ! $UPDATE_MYSQL || $_new_cnf_needed ; then + echononl "Erstelle Konfigurationsdatei ${MYSQL_INSTALL_DIR}/etc/my.cnf.." + + echo "" >> ${logdir}/main.log + echo "## - Erstelle Konfigurationsdatei ${MYSQL_INSTALL_DIR}/etc/my.cnf" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "_number_cpus=`grep "^processor" /proc/cpuinfo | sort -u | wc -l`" >> ${logdir}/main.log + _number_cpus=`grep "^processor" /proc/cpuinfo | sort -u | wc -l` + + echo "" >> ${logdir}/main.log + echo "let MYSQL_THREAD_CONCURRENCY=$_number_cpus*2" >> ${logdir}/main.log + let MYSQL_THREAD_CONCURRENCY=$_number_cpus*2 + + echo "" >> ${logdir}/main.log + echo "\$MYSQL_THREAD_CONCURRENCY = $MYSQL_THREAD_CONCURRENCY" >> ${logdir}/main.log + + echo "cat << EOF > ${MYSQL_INSTALL_DIR}/etc/my.cnf +# Example MySQL config file for very large systems. +# +# This is for a large system with memory of 1G-2G where the system runs mainly +# MySQL. +# +# You can copy this file to +# /etc/my.cnf to set global options, +# mysql-data-dir/my.cnf to set server-specific options (in this +# installation this directory is /var/lib/mysql) or +# ~/.my.cnf to set user-specific options. +# +# In this file, you can use all long options that a program supports. +# If you want to know which options a program supports, run the program +# with the \"--help\" option. + +# The following options will be passed to all MySQL clients +[client] +port = $MYSQL_PORT +socket = $MYSQL_UNIX_SOCKET + +default-character-set = utf8mb4 + +# Here follows entries for some specific programs +# The following values assume you have at least 32M ram + +# This was formally known as [safe_mysqld]. Both versions are currently parsed. +[mysqld_safe] +port = $MYSQL_PORT +socket = $MYSQL_UNIX_SOCKET +" >> ${logdir}/main.log + + if [[ -n "$MYSQL_X_UNIX_SOCKET" ]] ; then + echo " +mysqlx_port = $MYSQL_X_PORT +mysqlx_socket = $MYSQL_X_UNIX_SOCKET +" >> ${logdir}/main.log + fi + + echo " +nice = 0 + +open-files-limit = $(ulimit -Hn) +innodb-open-files = $(ulimit -Hn) + + +# The MySQL server +[mysqld] +port = $MYSQL_PORT +socket = $MYSQL_UNIX_SOCKET +" >> ${logdir}/main.log + + if [[ -n "$MYSQL_X_UNIX_SOCKET" ]] ; then + echo " +mysqlx_port = $MYSQL_X_PORT +mysqlx_socket = $MYSQL_X_UNIX_SOCKET +" >> ${logdir}/main.log + fi + + if [[ -n "$SYSTEMD_PID_DIR" ]] && [[ "$SYSTEMD_PID_DIR" != "/tmp" ]]; then + echo " +pid-file = ${SYSTEMD_PID_DIR}/mysqld.pid +" >> ${logdir}/main.log + fi + + echo " + +## - character-set-server +## - +## - The servers default character set. If you set this variable, you should also +## - set collation_server to specify the collation for the character set. +## - +## - See also: https://dev.mysql.com/doc/refman/8.0/en/charset-configuration.html +## - +## - The default depend on cmake options: +## - +## - cmake . \ +## - ... +## - -DDEFAULT_CHARSET=latin1 \ +## - -DDEFAULT_COLLATION=latin1_german1_ci +## - +#character-set-server = utf8 +character-set-server = utf8mb4 + +## - collation-server +## - +## - The server's default collation. See Section 10.14, “Character Set Configuration. +#collation-server = utf8_general_ci +collation-server = utf8mb4_general_ci + +" >> ${logdir}/main.log + + if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] ; then + + echo " +## - sql_mode +## - +## - The default on MariaDB 10.5 installation is: +## - +## - sql-mode = \"STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\" +## - +## - For now, we will use the default value - iIt seems to be ok. +## - +## - +## - Other defaults on MySQL installations: +## - +## - MySQL 8.0 +## - +## - Since Version 8.0.11 NO_AUTO_CREATE_USER is no longer available. The default on 8.0 MySQL +## - installations is +## - +## - sql-mode = \"ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\" +## - +" >> ${logdir}/main.log + + elif [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + echo " +## - sql_mode +## - +## - Since Version 8.0.11 NO_AUTO_CREATE_USER is no longer available. The default on 8.0 MySQL +## - installations is +## - +## - sql-mode = \"ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\" +## - +## - For now, we will use the default value, without deprecated NO_ZERO_IN_DATE and NO_ZERO_DATE (see below). +## - It seems to be ok. +## - +## - +## - The default on MariaDB 10.5 installation is: +## - +## - sql-mode = \"STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\" +" >> ${logdir}/main.log + + else + echo " +## - sql_mode +## - +## - To be compartible with older programming on mysql 5.6 use; +## - +## - sql-mode = \"ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\" +## - +" >> ${logdir}/main.log + + fi + + echo " +## - +## - The default on 5.7 MySQL installations was: +## - +## - sql-mode = \"ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\" +## - +## - +## - NOTE (note on version 5.7): +## - +## - NO_ZERO_DATE, NO_ZERO_IN_DATE and ERROR_FOR_DIVISION_BY_ZERO are deprecated, and all of them +## - are not part of strict mode, but should be used in conjunction with strict mode and are enabled +## - by default. A warning occurs if NO_ZERO_DATE or NO_ZERO_IN_DATE is enabled without also enabling +## - strict mode or vice versa. For additional discussion, see SQL Mode Changes in MySQL 5.7. +## - +## - +## - Because NO_ZERO_DATE, NO_ZERO_IN_DATE and ERROR_FOR_DIVISION_BY_ZERO are deprecated, expect it to +## - be removed in a future release of MySQL as a separate mode name and its effect included in the effects +## - of strict SQL mode. +## - +" >> ${logdir}/main.log + + if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] ; then +echo " +#sql-mode = \"ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\" +" >> ${logdir}/main.log + + elif [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + echo " +sql-mode = \"ONLY_FULL_GROUP_BY STRICT_TRANS_TABLES ERROR_FOR_DIVISION_BY_ZERO NO_ENGINE_SUBSTITUTION\" +" >> ${logdir}/main.log + + else + echo " +#sql-mode = \"ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\" +sql-mode = \"ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\" +" >> ${logdir}/main.log + fi + + echo " + +## - Which protocols the server permits for encrypted connections. The value is a +## - comma-separated list containing one or more protocol versions. The protocols +## - that can be named for this variable depend on the SSL library used to compile +## - MySQL. Permitted protocols should be chosen such as not to leave 'holes' in the +## - list. For details, see Section 6.3.2, Encrypted Connection TLS Protocols and Ciphers. +## - +## - NOTE: +## - As of MySQL 5.7.35, the TLSv1 and TLSv1.1 connection protocols are deprecated +## - and support for them is subject to removal in a future version of MySQL. See +## - Deprecated TLS Protocols. +## - +tls_version=TLSv1.2,TLSv1.3 + +## - secure_file_priv +## - +## - This variable is used to limit the effect of data import and export operations, +## - such as those performed by the LOAD DATA and SELECT ... INTO OUTFILE statements +## - and the LOAD_FILE() function. These operations are permitted only to users who +## - have the FILE privilege. +## - +## - i.e.: GRANT FILE on *.* to piwik@localhost +## - +## - secure_file_priv may be set as follows: +## - +## - - If empty, the variable has no effect. (That means no restrictions). +## - This is not a secure setting. +## - - If set to the name of a directory, the server limits import and export +## - operations to work only with files in that directory. The directory +## - must exist; the server will not create it. +## - - If set to NULL, the server disables import and export operations. +## - This value is permitted as of MySQL 5.7.6. +## - +## - Since MySQL v 5.7.16 the default 'secure_file_priv' value has changed +## - +## - NULL (>= MySQL 5.7.16), empty (< MySQL 5.7.16) +## - +## - We use empty (\"\") +## - +## - Note: +## - We changed the default to empty (\"\") while building from source +## - using CMake option (-DINSTALL_SECURE_FILE_PRIVDIR=\"\"). So you can ignore +## - this option. +## - +#secure-file-priv = \"\" +secure-file-priv = \"\" + + +## - local_infile +## - +## - This variable controls server-side LOCAL capability for LOAD DATA statements. +## - Depending on the local_infile setting, the server refuses or permits local data +## - loading by clients that have LOCAL enabled on the client side. +## - +## - You can check your 'local-infile' setting on mysql prompt: +## - +## - SHOW GLOBAL VARIABLES LIKE 'local_infile'; +## - +#local-infile = 1 + + +## - skip_external_locking +## - +## - Affects only MyISAM table access. +## - +## - This is OFF if mysqld uses external locking (system locking), +## - ON if external locking is disabled. +## - +## - Default: 1 oder ON +## - +skip_external_locking = 1 + + +# Don't listen on a TCP/IP port at all. This can be a security enhancement, +# if all processes that need to connect to mysqld run on the same host. +# All interaction with mysqld must be made via Unix sockets or named pipes. +# Note that using this option without enabling named pipes on Windows +# (via the "enable-named-pipe" option) will render mysqld useless! +# +#skip-networking + + +## - skip_name_resolve +## - +## - If set to 1 (0 is the default), only IP addresses are used for connections. +## - Host names are not resolved. All host values in the GRANT tables must be +## - IP addresses (or localhost). +## - +## - Default vaue is: 0 oder OFF +## - +#skip_name_resolve = 0 + + +# 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 +bind-address = 127.0.0.1 + + +# Replication Master Server (default) +# binary logging is required for replication +#log-bin=mysql-bin + +# required unique id between 1 and 2^32 - 1 +# defaults to 1 if master-host is not set +# but will not function as a master if omitted +server-id = 1 + +# Replication Slave (comment out master section to use this) +# +# To configure this host as a replication slave, you can choose between +# two methods : +# +# 1) Use the CHANGE MASTER TO command (fully described in our manual) - +# the syntax is: +# +# CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=, +# MASTER_USER=, MASTER_PASSWORD= ; +# +# where you replace , , by quoted strings and +# by the master's port number (3306 by default). +# +# Example: +# +# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, +# MASTER_USER='joe', MASTER_PASSWORD='secret'; +# +# OR +# +# 2) Set the variables below. However, in case you choose this method, then +# start replication for the first time (even unsuccessfully, for example +# if you mistyped the password in master-password and the slave fails to +# connect), the slave will create a master.info file, and any later +# change in this file to the variables' values below will be ignored and +# overridden by the content of the master.info file, unless you shutdown +# the slave server, delete master.info and restart the slaver server. +# For that reason, you may want to leave the lines below untouched +# (commented) and instead use CHANGE MASTER TO (see above) +# +# required unique id between 2 and 2^32 - 1 +# (and different from the master) +# defaults to 2 if master-host is set +# but will not function as a slave if omitted +#server-id = 2 +# +# The replication master for this slave - required +#master-host = +# +# The username the slave will use for authentication when connecting +# to the master - required +#master-user = +# +# The password the slave will authenticate with when connecting to +# the master - required +#master-password = +# +# The port the master is listening on. +# optional - defaults to 3306 +#master-port = +# +# binary logging - not required for slaves, but recommended +#log-bin=mysql-bin +# +# binary logging format - mixed recommended +#binlog_format=mixed + +# Point the following paths to different dedicated disks +#tmpdir = /tmp/ +#log-update = /path-to-dedicated-directory/hostname + + +## - max_connections +## - +## - Die zulässige Anzahl nebenläufiger Clientverbindungen. Wenn dieser Wert erhöht +## - wird, erhöht sich auch die Anzahl der Dateideskriptoren, die mysqld benötigt. +## - +## - Vorgabewert ist 100 +## - +#max-connections = 300 + + +## - explicit-defaults_for_timestamp +## - +## - This variable was added in MySQL 5.6.6 +## - +## - In MySQL, the TIMESTAMP data type differs in nonstandard ways +## - from other data types. See MySQL Dokumentation. +## - +## - [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. +## - Please use --explicit_defaults_for_timestamp server option (see +## - documentation for more details). +## - +## - As indicated by the warning, to turn off the nonstandard behaviors, +## - enable the new . +## - +explicit-defaults-for-timestamp = TRUE + + +## - MySQL Fehlermeldungen +## - +## - !! Notice +## - erst ab für mysql 5.5.x +## - +## - lc-messages=de_DE +## - lc-messages-dir=$(dirname $MYSQL_INSTALL_DIR)/mysql/share +## - +## - bis 5.1.x +## - +## - language=$(dirname $MYSQL_INSTALL_DIR)/mysql/share/german +## - + + +## - low-priority-updates +## - +## - Give table-modifying operations (INSERT, REPLACE, DELETE, +## - UPDATE) lower priority than selects. +## - +## - +low-priority-updates = 1 + + +## - concurrent_insert +## - +## - If activated (1 or AUTO, the default), MySQL permits INSERT +## - and SELECT statements to run concurrently for MyISAM tables +## - that have no free blocks in the middle of the data file. +## - +## - If set to 2 or ALWAYS, MySQL enables concurrent inserts for +## - all MyISAM tables, even those that have holes. For a table with +## - a hole, new rows are inserted at the end of the table if it is +## - in use by another thread. Otherwise, MySQL acquires a normal +## - write lock and inserts the row into the hole. +## - +concurrent-insert = 2 + + +## - open_files_limit +## - +## - put the following lines into /etc/security/limits.conf +## - +## - @staff hard nofile 32768 +## - root hard nofile 32768 +## - +## - see also http://linux-vserver.org/Ulimit_Nofiles +## - +open-files-limit = $(ulimit -Hn) +innodb-open-files = $(ulimit -Hn) + + +## ------------------------- +## InnoDB specific variables + +## - innodb_file_per_table +## - +## - When innodb_file_per_table is enabled (the default in 5.6.6 and higher), +## - InnoDB stores the data and indexes for each newly created table in a +## - separate .ibd file, rather than in the system tablespace. +## - +innodb-file-per-table = 1 + +## - innodb_data_home_dir +## - +## - Default: MySQL data directory +## - +#innodb-data-home-dir = /data/mysql + +#innodb-data-file-path = ibdata1:2000M;ibdata2:10M:autoextend + +## - innodb_log_group_home_dir +## - +## - The directory path to the InnoDB redo log files, whose number +## - is specified by innodb_log_files_in_group. +## - +## - If you do not specify any InnoDB log variables, the default is +## - to create two files named ib_logfile0 and ib_logfile1 in the MySQL +## - data directory. Their size is given by the size of the +## - innodb_log_file_size system variable. +## - +#innodb_log-group-home-dir = /var/lib/mysql/ + +## - innodb_buffer_pool_size +## - +## - The size in bytes of the buffer pool, the memory area where InnoDB +## - caches table and index data. +## - +## - You can set .._buffer_pool_size up to 50 - 80 % +## - of RAM but beware of setting memory usage too high +## - +## - Note: +## - When the size of the buffer pool is greater than 1GB, setting +## - innodb_buffer_pool_instances to a value greater than 1 can improve +## - the scalability on a busy server. +## - +## - default: 134217728 (128M) +## - +#innodb-buffer-pool-size = 384M +#innodb-buffer-pool-size = 1024M +innodb_buffer_pool_size = 4G + + +## - innodb_additional_mem_pool_size +## - +## - The size in bytes of a memory pool InnoDB uses to store data dictionary +## - information and other internal data structures. +## - +## - Default: 8388608 (8M) +## - +## - Note !! +## - innodb_additional_mem_pool_size is deprected since version 5.6.3 +## - innodb_additional_mem_pool_size is removed since version 5.7 +## - +#innodb-additional-mem_pool-size = 20M +#innodb-additional-mem_pool-size = 40M + + +## - innodb_buffer_pool_instances +## - +## - The number of regions that the InnoDB buffer pool is divided into. +## - +## - Note: +## - For systems with buffer pools in the multi-gigabyte range, dividing +## - the buffer pool into separate instances can improve concurrency, by +## - reducing contention as different threads read and write to cached pages. +## - +## - Default: 1 +## - +#innodb-buffer-pool-instances = 1 + + +## - innodb_log_file_size +## - +## - The size in bytes of each log file in a log group. +## - +## - Default: +## - 50331648 (50M) (MySQL) +## - 100663296 (96MB) (>= MariaDB 10.5) +## - 50331648 (48MB) (<= MariaDB 10.4) +## - +## - (Set .._log_file_size to 25 % of buffer pool size) +## - +#innodb-log-file-size = 100M +#innodb-log-file-size = 256M +innodb_log_file_size = 512M + +## - innodb_log_buffer_size +## - +## - The size in bytes of the buffer that InnoDB uses to write to the +## - log files on disk. +## - +## - Default: 16777216 (16M) +## - +#innodb-log-buffer-size = 8M +#innodb-log-buffer-size = 32M + +## - innodb_flush_log_at_trx_commit +## - +## - Controls the balance between strict ACID compliance for commit +## - operations, and higher performance that is possible when +## - commit-related I/O operations are rearranged and done in batches. +## - You can achieve better performance by changing the default value, +## - but then you can lose up to one second worth of transactions in a crash. +## - +## - In case of extrem slowly restores set +## - +## - innodb_flush_log_at_trx_commit = 2 +## - innodb_log_file_size = 256M +## - +## - Also try to add (befor DROP/CREATE/INSET Statements) to the dumpfile: +## - +## - ... +## - SET FOREIGN_KEY_CHECKS=0; +## - SET unique_checks=0; +## - SET AUTOCOMMIT=0; +## - +## - DROP TABLE IF EXISTS.. +## - ... +## - +## - Default: innodb-flush-log-at-trx-commit = 1 +## - +#innodb-flush-log-at-trx-commit = 1 +#innodb-flush-log-at-trx-commit = 2 + +## - innodb_lock_wait_timeout +## - +## - The length of time in seconds an InnoDB transaction waits for a row +## - lock before giving up. +## - +## - Default: 50 +## - +#innodb-lock-wait-timeout = 50 + +## InnoDB specific variables +## ------------------------- + + +## - sort_buffer_size +## - +## - Each session that needs to do a sort allocates a buffer of this size. +## - sort_buffer_size is not specific to any storage engine and applies +## - in a general manner for optimization. +## - +## - Default: 2097152 (2M) +## - +sort-buffer-size = 2M + + +## - key_buffer_size +## - +## - key_buffer_size is a MyISAM parameter ! +## - +## - Index blocks for MyISAM tables are buffered and are shared by all threads. +## - key_buffer_size is the size of the buffer used for index blocks. The key +## - buffer is also known as the key cache. +## - +## - Default: 8388608 (8M) +## - +#key-buffer-size = 384M +key_buffer_size = 512M + + +## - read_buffer_size +## - +## - Each thread that does a sequential scan for a MyISAM table allocates +## - a buffer of this size (in bytes) for each table it scans. If you do +## - many sequential scans, you might want to increase this value. +## - +## - Default: 131072 (128K) +## - +read-buffer-size = 2M + +## - read_rnd_buffer_size +## - +## - This variable is used for reads from MyISAM tables, and, for any +## - storage engine, for Multi-Range Read optimization. +## - +## - Default: 262144 (256K) +## - +read-rnd-buffer-size = 8M + + +## - myisam_sort_buffer_size +## - +## - The size of the buffer that is allocated when sorting MyISAM indexes +## - during a REPAIR TABLE or when creating indexes with CREATE INDEX or +## - ALTER TABLE. +## - +## - Default: 8388608 (8M) +## - +myisam_sort_buffer_size = 64M + + +## - max_allowed_packet +## - +## - The maximum size of one packet or any generated/intermediate string, or +## - any parameter sent by the mysql_stmt_send_long_data() C API function. +## +## - Default: 4MB (MySQL 5.6.6), 1MB before that. +## - +#max-allowed-packet = 4M +#max-allowed-packet = 32M +max-allowed-packet = 128M + + +## - table_open_cache +## - +## - The number of open tables for all threads. Increasing this value +## - increases the number of file descriptors that mysqld requires. +## - +## - You can check whether you need to increase the table cache by checking +## - the Opened_tables status variable. If the value of Opened_tables is large +## - and you do not use FLUSH TABLES often (which just forces all tables to be +## - closed and reopened), then you should increase the value of the +## - table_open_cache variable. +## - +#table-open-cache = 512 +#table_open_cache = 1024 +#table_open_cache = 6144 +table_open_cache = 8192 + +## - table_definition_cache +## - +## - The number of table definitions (from .frm files) that can be stored +## - in the definition cache. +## - +## - Default: (400 + (table_open_cache / 2) since 5.6.8, 400 before +## - +#table-definition-cache = 1680 +table_definition_cache = 5120 + +## - max-connect-errors +## - +## - Default: 100 (5.6.6), 10 (before) +## - +max-connect-errors = 999999 + +## - thread_concurrency +## - +## - NOTE: +## - This variable is specific to Solaris 8 and earlier systems. +## - +## - This variable is deprecated as of MySQL 5.6.1 and is removed in MySQL 5.7. +## - You should remove this from MySQL configuration files whenever you see it +## - unless they are for Solaris 8 or earlier +## - +## - (Try number of CPU's*2 for thread_concurrency) +## - +#thread-concurrency = 16 + +## - thread_cache_size +## - +## - How many threads the server should cache for reuse. When a client +## - disconnects, the client's threads are put in the cache if there are +## - fewer than thread_cache_size threads there. +## - +## - Default: 8 + (max_connections / 100) (5.6.8) , 0 (before) +## - +#thread-cache-size = 8 +thread_cache_size = 32 + +## - thread_stack +## - +## - The stack size for each thread. Many of the limits detected by +## - the crash-me test are dependent on this value. +## - +## - The default of 192KB (256KB for 64-bit systems) is large enough +## - for normal operation. If the thread stack size is too small, it +## - limits the complexity of the SQL statements that the server can handle, +## - the recursion depth of stored procedures, and other memory-consuming +## - actions. +## - Default: 262144 (256K) +## - +thread-stack = 262144 + + +## - Unbenutze Datenbank Engines deaktivieren +## - + +## - skip-innodb +## - +## - Deaktiviert die Unterstützung für InnoDB +## - +## - Sincs version 5.5, you have to set default-storage-engine +## - to MyISAM, if using skip-innodb +## - +#default-storage-engine=MyISAM +#skip-innodb + + +## - log-error +## - +## - Log errors and startup messages to this file. If you omit the file +## - name, MySQL uses host_name.err. If the file name has no extension, +## - the server adds an extension of .err. +## - +log-error = $_mysql_error_log + + +## - Query Log +## - +#general-log = on +#general-log-file = $_mysql_log + + +## - ft_min_word_len +## - +## - Die minimale Länge des Wortes, das in einem FULLTEXT-Index enthalten sein darf. +## - +## - Notice! +## - if you set +## - [mysqld] +## - ft_min_word_len=3 +## - +## - you should also set +## - [myisamchk] +## - ft_min_word_len=3 +## - +## - +## - Vorgabewert ist 4 +#ft-min-word-len = 3 + +## - ft_stopword_file +## - +## - Datei, aus der die Liste der Stoppwörter für die Volltextsuche ausgelesen wird. +## - Es werden alle Wörter aus der Datei verwendet; Kommentare hingegen werden nicht +## - berücksichtigt. Standardmäßig wird eine eingebaute Liste mit Stoppwörtern (wie +## - in der Datei myisam/ft_static.c definiert) verwendet. Wird diesee Variable auf den +## - Leer-String gesetzt (''), wird die Ausfilterung von Stoppwörtern deaktiviert. +## - +## - Hinweis: Wird diese Variable geändern oder den Inhalt der Stoppwortdatei selbst, +## - müssen die FULLTEXT-Indizes neu erstellt werden (REPAIR TABLE tbl_name QUICK. ). +## - +#ft-stopword-file = /usr/local/mysql/stopwords_utf8_iso8859-15.txt + + + +## ------------- +## - query cache + + +## - query_cache_type +## - +## - 0 : verhindert das Speichern von Abfragen im und +## - das Abrufen aus dem Cache +## - 1 : gestattet das Speichern von Abfragen im Cache. +## - Ausgenommen sind Anweisungen, die mit +## - SELECT SQL_NO_CACHE beginnen. +## - 2 : speichert nur diejenigen Anweisungen im Cache, +## - die mit SELECT SQL_CACHE beginnen. +" >> ${logdir}/main.log + + if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + echo " +## - +## - Removed since Version 8.0.3 +## - +#query_cache_type = 1" >> ${logdir}/main.log + + else + echo "query-cache-type = 1" >> ${logdir}/main.log + fi + + echo " + +## - query_cache_limit +## - +## - Gibt die maximale Größe einzelner Abfrageergebnisse an, die im +## - Cache gespeichert werden können. +## - +## - Vorgeabewert ist 1Mbyte +## - +" >> ${logdir}/main.log + + if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + echo " +## - +## - Removed since Version 8.0.3 +## - +#query-cache-limit = 4M" >> ${logdir}/main.log + + else + echo "#query-cache-limit = 4M" >> ${logdir}/main.log + echo "query-cache-limit = 16M" >> ${logdir}/main.log + fi + + echo " + +## - query_cache_min_res_unit +## - +## - Die im Abfrage-Cache abgelegten Ergebnisse, werden nicht am Stück +## - verwaltet. Der Abfrage-Cache reserviert Blöcke zur Speicherung dieser +## - Daten nach Bedarf, d. h. wenn ein Block voll ist, wird der nächste +## - zugewiesen. Da der Speicherreservierungsvorgang (in zeitlicher Hinsicht) +## - aufwändig ist, reserviert der Abfrage-Cache die Blöcke mit einer +## - Mindestgröße, die durch die Systemvariable query_cache_min_res_unit +## - festgelegt wird. Wird eine Abfrage ausgeführt, dann wird der letzte +## - Ergebnisblock auf die tatsächliche Datengröße zugeschnitten, sodass +## - unbenutzter Speicher freigegeben wird. +## - +## - Siehe auch http://dev.mysql.com/doc/refman/5.1/de/query-cache-configuration.html +## - +## - Vorgabewert ist 4Kbyte +## - +" >> ${logdir}/main.log + + if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + echo " +## - +## - Removed since Version 8.0.3 +## - +#query-cache-min-res-unit = 8K" >> ${logdir}/main.log + + else + echo "query-cache-min-res-unit = 8K" >> ${logdir}/main.log + fi + + echo " + +## - query_cache_size +## - +## - Die Größe des Abfrage-Caches. +## - +## - Wird query_cache_size auf einen Wert größer Null gesetzt, so ist zu beachten, +## - dass der Abfrage-Cache eine Mindestgröße von ca. 40 Kbyte benötigt, um seine +## - Strukturen zuzuweisen. (Der exakte Wert hängt von der Systemarchitektur ab.) +## - Wird der Wert zu niedrig angesetzt, wird eine Warnung ausgegeben. +## - +## - Vorgabewert ist 0, d. h. der Abfrage-Cache ist vorgabeseitig deaktiviert. +## - +" >> ${logdir}/main.log + + if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + echo " +## - +## - Removed since Version 8.0.3 +## - +#query-cache-size = 32M +#query-cache-size = 128M" >> ${logdir}/main.log + + else + echo "#query-cache-size = 128M +#query-cache-size = 512M +query-cache-size = 1024M" >> ${logdir}/main.log + fi + + echo " + +## - query cache +## ------------- + + +## -------------- +## - slow queries + +## - slow_query_log +## - +## - Gibt an, ob das Logging für langsame Abfragen eingeschaltet (1 oder ON) +## - bzw ausgeschaltet (0 oder OFF) ist. +## - +## - Vorgabewert ist 0 oder OFF +## - +slow-query-log = 1 + + +## - long_query_time +## - +## - Wenn eine Abfrage länger dauert als durch diese Variable (in Sekunden) angegeben, +## - erhöht der Server die Statusvariable Slow_queries entsprechend. Wird die Option +## - --log-slow-queries verwendet, wird die Abfrage in der Logdatei für langsame Abfragen +## - protokolliert. Dieser Wert wird als Echtzeit (nicht als Prozessorzeit) gemessen, d. h. +## - eine Abfrage, die bei einem System mit geringer Belastung den Schwellwert +## - unterschreitet, kann bei einem stark belasteten System bereits darüber liegen. +## - Der Mindestwert ist 1. +## - +## - Vorgabewert ist 10 +## - +long-query-time = 1 + + +## - slow_query_log_file +## - +## - Name der Logdatei, in die langsame Abfragen gespeichert werden. +## - +## - Vorgabewert ist -slow.log +## - +slow-query-log-file = $_mysql_slow_query_log + + +## - log-queries-not-using-indexes +## - +## - Gibt an, ob Abfragen, die keine Indizes benutzen in der Logdatei +## - für langsame Abfragen mitgespeichert werden sollen. +## - +## - Vorgabewert ist 0 +## - +#log-queries-not_using_indexes = 1 +log-queries-not-using-indexes = 0 + +## - slow queries +## -------------- + +## - join_buffer_size +## - +## - Die Größe des Puffers, der für Joins benutzt wird, die keine Indizes verwenden +## - und deswegen vollständige Tabellenscans durchführen. Normalerweise besteht die +## - beste Möglichkeit der Realisierung schneller Joins darin, Indizes hinzuzufügen. +## - Erhöhen Sie den Wert von join_buffer_size, um einen schnelleren vollständigen +## - Join zu implementieren, wenn das Hinzufügen von Indizes nicht möglich ist. Für +## - jeden vollständigen Join zwischen zwei Tabellen wird ein Join-Puffer hinzugefügt. +## - Für einen komplexen Join zwischen mehreren Tabellen, für den Indizes nicht verwendet +## - werden, sind unter Umständen mehrere Join-Puffer erforderlich. +## - +## - Wird die Option --log-slow-queries (ON) verwendet, werden Abfragen, die keine +## - Indizes verwenden, in das Log für langsame Abfragen geschrieben. +## - +## - Vorgabewert ist 128K +## - +#join-buffer-size = 384K +#join_buffer_size = 768K +#join_buffer_size = 1024K +join_buffer_size = 1536K + + + +## - max_heap_table_size +## - +## - Diese Variable bestimmt die maximale Größe, auf die MEMORY-Tabellen anwachsen dürfen. +## - Der Wert der Variable wird zur Berechnung von MAX_ROWS-Werte für MEMORY-Tabellen +## - verwendet. Die Einstellung der Variable hat keine Auswirkungen auf bereits vorhandene +## - MEMORY-Tabellen, sofern diese nicht mit einer Anweisung wie CREATE TABLE neu erstellt +## - oder mit ALTER TABLE oder TRUNCATE TABLE modifiziert werden. +## - +## - Vorgabewert ist 16Mbyte +## - +#max-heap-table-size = 96M +#max_heap_table_size = 128M +#max_heap_table_size = 768M +#max_heap_table_size = 1024M +max_heap_table_size = 2048M + + +## - tmp_table_size +## - +## - Überschreitet eine temporäre Tabelle im Arbeitsspeicher diese Größe, wandelt MySQL +## - sie automatisch in eine MyISAM-Tabelle auf der Festplatte um. +## - +## - Werden viele erweiterte GROUP-BY-Anfragen ausgeführt (und ist genügend Speicher +## - vorhanden), so sollte diese Variable erhöht werden. +## +## - Default: 16777216 (16M) +## - +## - Note: +## - Effective in-memory tmp_table_size is limited to max_heap_table_size. +## - +#tmp-table-size = 96M +#tmp_table_size = 768M +tmp_table_size = 2048M + + +# This group is only read by MariaDB servers, not by MySQL. +# If you use the same .cnf file for MySQL and MariaDB, +# you can put MariaDB-only options here +[mariadb] + +## - innodb_purge_threads +## - +## - Number of background threads dedicated to InnoDB purge operations. The range +## - is 1 to 32. At least one background thread is always used from MariaDB 10.0. +## - +## - The default has been increased from 1 to 4 in MariaDB 10.2.2. Setting to a +## - value greater than 1 creates that many separate purge threads. This can improve +## - efficiency in some cases, such as when performing DML operations on many tables. +## - In MariaDB 5.5, the options are 0 and 1. If set to 0, the default, purging is +## - done with the primary thread. If set to 1, purging is done on a separate thread, +## - which could reduce contention. See also innodb_purge_batch_size. +## - +## - Default Value: +## - +## - 4 (>= MariaDB 10.2.2) +## - 1 (>=MariaDB 10.0 to <= MariaDB 10.2.1) +#innodb_purge_threads = 4 + + +## ------------- +## - query cache + +## - query_cache_type +## - +## - 0 : verhindert das Speichern von Abfragen im und +## - das Abrufen aus dem Cache +## - 1 : gestattet das Speichern von Abfragen im Cache. +## - Ausgenommen sind Anweisungen, die mit +## - SELECT SQL_NO_CACHE beginnen. +## - 2 : speichert nur diejenigen Anweisungen im Cache, +## - die mit SELECT SQL_CACHE beginnen. +## - +## - Removed since MySQL Version 8.0.3 +## - +## - But present at MariaDB +## - +#query_cache_type = 1 +query_cache_type = 0 + + +## - query_cache_limit +## - +## - Gibt die maximale Größe einzelner Abfrageergebnisse an, die im +## - Cache gespeichert werden können. +## - +## - Vorgeabewert ist 1Mbyte +## - +## - Removed since MySQL Version 8.0.3 +## - +## - But present at MariaDB +## - +#query-cache-limit = 4M +query-cache-limit = 16M + + +## - query_cache_min_res_unit +## - +## - Die im Abfrage-Cache abgelegten Ergebnisse, werden nicht am Stück +## - verwaltet. Der Abfrage-Cache reserviert Blöcke zur Speicherung dieser +## - Daten nach Bedarf, d. h. wenn ein Block voll ist, wird der nächste +## - zugewiesen. Da der Speicherreservierungsvorgang (in zeitlicher Hinsicht) +## - aufwändig ist, reserviert der Abfrage-Cache die Blöcke mit einer +## - Mindestgröße, die durch die Systemvariable query_cache_min_res_unit +## - festgelegt wird. Wird eine Abfrage ausgeführt, dann wird der letzte +## - Ergebnisblock auf die tatsächliche Datengröße zugeschnitten, sodass +## - unbenutzter Speicher freigegeben wird. +## - +## - Siehe auch http://dev.mysql.com/doc/refman/5.1/de/query-cache-configuration.html +## - +## - Vorgabewert ist 4Kbyte +## - +## - +## - Removed since MySQL Version 8.0.3 +## - +## - But present at MariaDB +## - +#query_cache_min_res_unit = 8K + + +## - query_cache_size +## - +## - Die Größe des Abfrage-Caches. +## - +## - Wird query_cache_size auf einen Wert größer Null gesetzt, so ist zu beachten, +## - dass der Abfrage-Cache eine Mindestgröße von ca. 40 Kbyte benötigt, um seine +## - Strukturen zuzuweisen. (Der exakte Wert hängt von der Systemarchitektur ab.) +## - Wird der Wert zu niedrig angesetzt, wird eine Warnung ausgegeben. +## - +## - Vorgabewert ist 1Mbyte, d. h. der Abfrage-Cache ist vorgabeseitig deaktiviert. +## - +## - +## - Removed since MySQL Version 8.0.3 +## - +## - But present at MariaDB +## - +#query_cache_size = 128M +#query_cache_size = 512M +query_cache_size = 1024M + +## - query cache +## ------------- + +# This group is only read by MariaDB-10.3 servers. +# If you use the same .cnf file for MariaDB of different versions, +# use this group for options that older servers don't understand +[mariadb-10.3] + + +[mariadb-10.4] + + +[mariadb-10.6] + +## - innodb_read_only_compressed +## - +## - Make ROW_FORMAT=COMPRESSED tables read-only (ON by default) +## - +innodb_read_only_compressed = OFF + + +## - angepasste Einstellungen +## ------------------------------------------ + + +[mysqldump] +quick +max-allowed-packet = 1024M +default-character-set = utf8mb4 + + +[mysql] +no-auto-rehash +# Remove the next comment character if you are not familiar with SQL +#safe-updates +local-infile = 1 + + +[myisamchk] +key-buffer-size = 256M +sort-buffer-size = 256M +read-buffer = 2M +write-buffer = 2M + + +## ------------------------------------------ +## - angepasste Einstellungen + +## - ft_min_word_len +## - +## - Die minimale Länge des Wortes, das in einem FULLTEXT-Index enthalten sein darf. +## - +## - Notice! +## - if you set +## - [mysqld] +## - ft_min_word_len=3 +## - +## - you should also set +## - [myisamchk] +## - ft_min_word_len=3 +## - +## - +## - Vorgabewert ist 4 +#ft-min-word.len = 3 + +## - angepasste Einstellungen +## ------------------------------------------ + + +[mysqlhotcopy] +interactive-timeout + +" >> ${logdir}/main.log + + if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + + echo " +## - sql_mode +## - +## - Since Version 8.0.11 NO_AUTO_CREATE_USER is no longer available +## - +## - For now, we will use the default value, it seems to be ok. +## - +#sql-mode = \"ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\" + +EOF" >> ${logdir}/main.log + + else + echo " +## - sql_mode +## - +## - To be compartible with older programming on mysql 5.6 +## - +#sql-mode = "ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" + +EOF" >> ${logdir}/main.log + fi + + cat << EOF > ${MYSQL_INSTALL_DIR}/etc/my.cnf +# Example MySQL config file for very large systems. +# +# This is for a large system with memory of 1G-2G where the system runs mainly +# MySQL. +# +# You can copy this file to +# /etc/my.cnf to set global options, +# mysql-data-dir/my.cnf to set server-specific options (in this +# installation this directory is /var/lib/mysql) or +# ~/.my.cnf to set user-specific options. +# +# In this file, you can use all long options that a program supports. +# If you want to know which options a program supports, run the program +# with the "--help" option. + +# The following options will be passed to all MySQL clients +[client] +port = $MYSQL_PORT +socket = $MYSQL_UNIX_SOCKET + +default-character-set = utf8mb4 + +# Here follows entries for some specific programs +# The following values assume you have at least 32M ram + +# This was formally known as [safe_mysqld]. Both versions are currently parsed. +[mysqld_safe] +port = $MYSQL_PORT +socket = $MYSQL_UNIX_SOCKET +EOF + if [[ -n "$MYSQL_X_UNIX_SOCKET" ]] ; then + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +mysqlx_port = $MYSQL_X_PORT +mysqlx_socket = $MYSQL_X_UNIX_SOCKET +EOF + fi + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +nice = 0 + +open-files-limit = $(ulimit -Hn) +innodb-open-files = $(ulimit -Hn) + + +# The MySQL server +[mysqld] +port = $MYSQL_PORT +socket = $MYSQL_UNIX_SOCKET +EOF + if [[ -n "$MYSQL_X_UNIX_SOCKET" ]] ; then + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +mysqlx_port = $MYSQL_X_PORT +mysqlx_socket = $MYSQL_X_UNIX_SOCKET +EOF + fi + if [[ -n "$SYSTEMD_PID_DIR" ]] && [[ "$SYSTEMD_PID_DIR" != "/tmp" ]]; then + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +pid-file = ${SYSTEMD_PID_DIR}/mysqld.pid +EOF + fi + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf + + +## - character-set-server +## - +## - The servers default character set. If you set this variable, you should also +## - set collation_server to specify the collation for the character set. +## - +## - See also: https://dev.mysql.com/doc/refman/8.0/en/charset-configuration.html +## - +## - The default depend on cmake options: +## - +## - cmake . \ +## - ... +## - -DDEFAULT_CHARSET=latin1 \ +## - -DDEFAULT_COLLATION=latin1_german1_ci +## - +#character-set-server = utf8 +character-set-server = utf8mb4 + +## - collation-server +## - +## - The server's default collation. See Section 10.14, “Character Set Configuration. +#collation-server = utf8_general_ci +collation-server = utf8mb4_general_ci + +EOF + + if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] ; then + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +## - sql_mode +## - +## - The default on MariaDB 10.5 installation is: +## - +## - sql-mode = "STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" +## - +## - For now, we will use the default value - iIt seems to be ok. +## - +## - +## - Other defaults on MySQL installations: +## - +## - MySQL 8.0 +## - +## - Since Version 8.0.11 NO_AUTO_CREATE_USER is no longer available. The default on 8.0 MySQL +## - installations is +## - +## - sql-mode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" +## - +EOF + + elif [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +## - sql_mode +## - +## - Since Version 8.0.11 NO_AUTO_CREATE_USER is no longer available. The default on 8.0 MySQL +## - installations is +## - +## - sql-mode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" +## - +## - For now, we will use the default value, without deprecated NO_ZERO_IN_DATE and NO_ZERO_DATE (see below). +## - It seems to be ok. +## - +EOF + + else + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf + +## - sql_mode +## - +## - To be compartible with older programming on mysql 5.6 use; +## - +## - sql-mode = "ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" +## - +EOF + + fi + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +## - +## - The default on 5.7 MySQL installations was: +## - +## - sql-mode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" +## - +## - +## - NOTE (on 5.7 installation): +## - +## - NO_ZERO_DATE, NO_ZERO_IN_DATE and ERROR_FOR_DIVISION_BY_ZERO are deprecated, and all of them +## - are not part of strict mode, but should be used in conjunction with strict mode and are enabled +## - by default. A warning occurs if NO_ZERO_DATE or NO_ZERO_IN_DATE is enabled without also enabling +## - strict mode or vice versa. For additional discussion, see SQL Mode Changes in MySQL 5.7. +## - +## - +## - Because NO_ZERO_DATE, NO_ZERO_IN_DATE and ERROR_FOR_DIVISION_BY_ZERO are deprecated, expect it to +## - be removed in a future release of MySQL as a separate mode name and its effect included in the effects +## - of strict SQL mode. +## - +EOF + + if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] ; then + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +#sql-mode = "ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" +EOF + + elif [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +sql-mode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" +EOF + + else + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +#sql-mode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" +sql-mode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" +EOF + fi + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf + +## - Which protocols the server permits for encrypted connections. The value is a +## - comma-separated list containing one or more protocol versions. The protocols +## - that can be named for this variable depend on the SSL library used to compile +## - MySQL. Permitted protocols should be chosen such as not to leave 'holes' in the +## - list. For details, see Section 6.3.2, “Encrypted Connection TLS Protocols and Ciphers. +## - +## - NOTE: +## - As of MySQL 5.7.35, the TLSv1 and TLSv1.1 connection protocols are deprecated +## - and support for them is subject to removal in a future version of MySQL. See +## - Deprecated TLS Protocols. +## - +tls_version=TLSv1.2,TLSv1.3 + +## - secure-file-priv +## - +## - This variable is used to limit the effect of data import and export operations, +## - such as those performed by the LOAD DATA and SELECT ... INTO OUTFILE statements +## - and the LOAD_FILE() function. These operations are permitted only to users who +## - have the FILE privilege. +## - +## - i.e.: GRANT FILE on *.* to piwik@localhost +## - +## - secure_file_priv may be set as follows: +## - +## - - If empty, the variable has no effect. (That means no restrictions). +## - This is not a secure setting. +## - - If set to the name of a directory, the server limits import and export +## - operations to work only with files in that directory. The directory +## - must exist; the server will not create it. +## - - If set to NULL, the server disables import and export operations. +## - This value is permitted as of MySQL 5.7.6. +## - +## - Since MySQL v 5.7.16 the default 'secure_file_priv' value has changed +## - +## - NULL (>= MySQL 5.7.16), empty (< MySQL 5.7.16) +## - +## - We use empty ("") +## - +## - Note: +## - We changed the default to empty ("") while building from source +## - using CMake option (-DINSTALL_SECURE_FILE_PRIVDIR=""). So you can ignore +## - this option. +## - +#secure-file-priv = "" +secure-file-priv = "" + + +## - local-infile +## - +## - This variable controls server-side LOCAL capability for LOAD DATA statements. +## - Depending on the local_infile setting, the server refuses or permits local data +## - loading by clients that have LOCAL enabled on the client side. +## - +## - You can check your 'local-infile' setting on mysql prompt: +## - +## - SHOW GLOBAL VARIABLES LIKE 'local_infile'; +## - +#local-infile = 1 + + +## - skip_external_locking +## - +## - Affects only MyISAM table access. +## - +## - This is OFF if mysqld uses external locking (system locking), +## - ON if external locking is disabled. +## - +## - Default: ON +## - +skip-external-locking + + +# Don't listen on a TCP/IP port at all. This can be a security enhancement, +# if all processes that need to connect to mysqld run on the same host. +# All interaction with mysqld must be made via Unix sockets or named pipes. +# Note that using this option without enabling named pipes on Windows +# (via the "enable-named-pipe" option) will render mysqld useless! +# +#skip-networking + + +# 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 +bind-address = 127.0.0.1 + + +# Replication Master Server (default) +# binary logging is required for replication +#log-bin=mysql-bin + +# required unique id between 1 and 2^32 - 1 +# defaults to 1 if master-host is not set +# but will not function as a master if omitted +server-id = 1 + +# Replication Slave (comment out master section to use this) +# +# To configure this host as a replication slave, you can choose between +# two methods : +# +# 1) Use the CHANGE MASTER TO command (fully described in our manual) - +# the syntax is: +# +# CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=, +# MASTER_USER=, MASTER_PASSWORD= ; +# +# where you replace , , by quoted strings and +# by the master's port number (3306 by default). +# +# Example: +# +# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, +# MASTER_USER='joe', MASTER_PASSWORD='secret'; +# +# OR +# +# 2) Set the variables below. However, in case you choose this method, then +# start replication for the first time (even unsuccessfully, for example +# if you mistyped the password in master-password and the slave fails to +# connect), the slave will create a master.info file, and any later +# change in this file to the variables' values below will be ignored and +# overridden by the content of the master.info file, unless you shutdown +# the slave server, delete master.info and restart the slaver server. +# For that reason, you may want to leave the lines below untouched +# (commented) and instead use CHANGE MASTER TO (see above) +# +# required unique id between 2 and 2^32 - 1 +# (and different from the master) +# defaults to 2 if master-host is set +# but will not function as a slave if omitted +#server-id = 2 +# +# The replication master for this slave - required +#master-host = +# +# The username the slave will use for authentication when connecting +# to the master - required +#master-user = +# +# The password the slave will authenticate with when connecting to +# the master - required +#master-password = +# +# The port the master is listening on. +# optional - defaults to 3306 +#master-port = +# +# binary logging - not required for slaves, but recommended +#log-bin=mysql-bin +# +# binary logging format - mixed recommended +#binlog_format=mixed + +# Point the following paths to different dedicated disks +#tmpdir = /tmp/ +#log-update = /path-to-dedicated-directory/hostname + + +## - max_connections +## - +## - Die zulässige Anzahl nebenläufiger Clientverbindungen. Wenn dieser Wert erhöht +## - wird, erhöht sich auch die Anzahl der Dateideskriptoren, die mysqld benötigt. +## - +## - Vorgabewert ist 100 +## - +#max-connections = 300 + + +## - explicit_defaults_for_timestamp +## - +## - This variable was added in MySQL 5.6.6 +## - +## - In MySQL, the TIMESTAMP data type differs in nonstandard ways +## - from other data types. See MySQL Dokumentation. +## - +## - [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. +## - Please use --explicit_defaults_for_timestamp server option (see +## - documentation for more details). +## - +## - As indicated by the warning, to turn off the nonstandard behaviors, +## - enable the new . +## - +explicit-defaults-for-timestamp = TRUE + + +## - MySQL Fehlermeldungen +## - +## - !! Notice +## - erst ab für mysql 5.5.x +## - +## - lc-messages=de_DE +## - lc-messages-dir=$(dirname $MYSQL_INSTALL_DIR)/mysql/share +## - +## - bis 5.1.x +## - +## - language=$(dirname $MYSQL_INSTALL_DIR)/mysql/share/german +## - + + +## - low-priority-updates +## - +## - Give table-modifying operations (INSERT, REPLACE, DELETE, +## - UPDATE) lower priority than selects. +## - +## - +low-priority-updates = 1 + + +## - concurrent_insert +## - +## - If activated (1 or AUTO, the default), MySQL permits INSERT +## - and SELECT statements to run concurrently for MyISAM tables +## - that have no free blocks in the middle of the data file. +## - +## - If set to 2 or ALWAYS, MySQL enables concurrent inserts for +## - all MyISAM tables, even those that have holes. For a table with +## - a hole, new rows are inserted at the end of the table if it is +## - in use by another thread. Otherwise, MySQL acquires a normal +## - write lock and inserts the row into the hole. +## - +concurrent-insert = 2 + + +## - open-files-limit +## - +## - put the following lines into /etc/security/limits.conf +## - +## - @staff hard nofile 32768 +## - root hard nofile 32768 +## - +## - see also http://linux-vserver.org/Ulimit_Nofiles +## - +open-files-limit = $(ulimit -Hn) +innodb-open-files = $(ulimit -Hn) + + +## ------------------------- +## InnoDB specific variables + +## - innodb_file_per_table +## - +## - When innodb_file_per_table is enabled (the default in 5.6.6 and higher), +## - InnoDB stores the data and indexes for each newly created table in a +## - separate .ibd file, rather than in the system tablespace. +## - +innodb-file-per-table = 1 + +## - innodb_data_home_dir +## - +## - Default: MySQL data directory +## - +#innodb-data-home_dir = /data/mysql + +#innodb-data-file-path = ibdata1:2000M;ibdata2:10M:autoextend + +## - innodb_log_group_home_dir +## - +## - The directory path to the InnoDB redo log files, whose number +## - is specified by innodb_log_files_in_group. +## - +## - If you do not specify any InnoDB log variables, the default is +## - to create two files named ib_logfile0 and ib_logfile1 in the MySQL +## - data directory. Their size is given by the size of the +## - innodb_log_file_size system variable. +## - +#innodb-log-group-home-dir = /var/lib/mysql/ + +## - innodb-buffer-pool-size +## - +## - The size in bytes of the buffer pool, the memory area where InnoDB +## - caches table and index data. +## - +## - You can set .._buffer_pool_size up to 50 - 80 % +## - of RAM but beware of setting memory usage too high +## - +## - Note: +## - When the size of the buffer pool is greater than 1GB, setting +## - innodb_buffer_pool_instances to a value greater than 1 can improve +## - the scalability on a busy server. +## - +## - default: 134217728 (128M) +## - +#innodb-buffer-pool-size = 384M +#innodb-buffer-pool-size = 1024M +innodb_buffer_pool_size = 4G + + +## - innodb_additional_mem_pool_size +## - +## - The size in bytes of a memory pool InnoDB uses to store data dictionary +## - information and other internal data structures. +## - +## - Default: 8388608 (8M) +## - +## - Note !! +## - innodb_additional_mem_pool_size is deprected since version 5.6.3 +## - innodb_additional_mem_pool_size is removed since version 5.7 +## - +## - innodb_additional_mem_pool_size is also removed on MariaDB 10.3.x +## - +#innodb-additional-mem-pool-size = 20M +#innodb-additional-mem-pool-size = 40M + + +## - innodb_buffer_pool_instances +## - +## - The number of regions that the InnoDB buffer pool is divided into. +## - +## - Note: +## - For systems with buffer pools in the multi-gigabyte range, dividing +## - the buffer pool into separate instances can improve concurrency, by +## - reducing contention as different threads read and write to cached pages. +## - +## - Default: 1 +## - +#innodb-buffer-pool-instances = 1 + + +## - innodb_log_file_size +## - +## - The size in bytes of each log file in a log group. +## - +## - Default: 5242880 (5M) +## - +## (Set .._log_file_size to 25 % of buffer pool size) +## - +#innodb-log-file-size = 100M +#innodb-log-file-size = 256M +innodb_log_file_size = 512M + +## - innodb_log_buffer_size +## - +## - The size in bytes of the buffer that InnoDB uses to write to the +## - log files on disk. +## - +## - Default: 8388608 (8M) +## - +#innodb-log-buffer-size = 8M +#innodb-log-buffer-size = 32M + +## - innodb_flush_log_at_trx_commit +## - +## - Controls the balance between strict ACID compliance for commit +## - operations, and higher performance that is possible when +## - commit-related I/O operations are rearranged and done in batches. +## - You can achieve better performance by changing the default value, +## - but then you can lose up to one second worth of transactions in a crash. +## - +## - In case of extrem slowly restores set +## - +## - innodb_flush_log_at_trx_commit = 2 +## - innodb_log_file_size = 256M +## - +## - Also try to add (befor DROP/CREATE/INSET Statements) to the dumpfile: +## - +## - ... +## - SET FOREIGN_KEY_CHECKS=0; +## - SET unique_checks=0; +## - SET AUTOCOMMIT=0; +## - +## - DROP TABLE IF EXISTS.. +## - +## - Default: innodb-flush-log-at-trx-commit = 1 +## - ... +## - +#innodb-flush-log-at-trx-commit = 1 +#innodb-flush-log-at-trx-commit = 2 + +## - innodb_lock_wait_timeout +## - +## - The length of time in seconds an InnoDB transaction waits for a row +## - lock before giving up. +## - +## - Default: 50 +## - +#innodb-lock-wait-timeout = 50 + +## InnoDB specific variables +## ------------------------- + + +## - sort_buffer_size +## - +## - Each session that needs to do a sort allocates a buffer of this size. +## - sort_buffer_size is not specific to any storage engine and applies +## - in a general manner for optimization. +## - +## - Default: 2097152 (2M) +## - +sort-buffer-size = 2M + + +## - key_buffer_size +## - +## - key_buffer_size is a MyISAM parameter +## - +## - Index blocks for MyISAM tables are buffered and are shared by all threads. +## - key_buffer_size is the size of the buffer used for index blocks. The key +## - buffer is also known as the key cache. +## - +## - Default: 8388608 (8M) +## - +#key-buffer-size = 384M +key_buffer_size = 512M + + +## - read_buffer_size +## - +## - Each thread that does a sequential scan for a MyISAM table allocates +## - a buffer of this size (in bytes) for each table it scans. If you do +## - many sequential scans, you might want to increase this value. +## - +## - Default: 131072 (128K) +## - +read-buffer-size = 2M + +## - read_rnd_buffer_size +## - +## - This variable is used for reads from MyISAM tables, and, for any +## - storage engine, for Multi-Range Read optimization. +## - +## - Default: 262144 (256K) +## - +read-rnd-buffer-size = 8M + + +## - myisam_sort_buffer_size +## - +## - The size of the buffer that is allocated when sorting MyISAM indexes +## - during a REPAIR TABLE or when creating indexes with CREATE INDEX or +## - ALTER TABLE. +## - +## - Default: 8388608 (8M) +## - +myisam-sort-buffer-size = 64M + + +## - max_allowed_packet +## - +## - The maximum size of one packet or any generated/intermediate string, or +## - any parameter sent by the mysql_stmt_send_long_data() C API function. +## +## - Default: 4MB (MySQL 5.6.6), 1MB before that. +## - +#max-allowed-packet = 4M +#max-allowed-packet = 32M +max-allowed-packet = 128M + + +## - table_open_cache +## - +## - The number of open tables for all threads. Increasing this value +## - increases the number of file descriptors that mysqld requires. +## - +## - You can check whether you need to increase the table cache by checking +## - the Opened_tables status variable. If the value of Opened_tables is large +## - and you do not use FLUSH TABLES often (which just forces all tables to be +## - closed and reopened), then you should increase the value of the +## - table_open_cache variable. +## - +#table-open-cache = 512 +#table_open_cache = 1024 +#table_open_cache = 6144 +table_open_cache = 8192 + +## - table_definition_cache +## - +## - The number of table definitions (from .frm files) that can be stored +## - in the definition cache. +## - +## - Default: (400 + (table_open_cache / 2) since 5.6.8, 400 before +## - +#table-definition-cache = 1680 +table_definition_cache = 5120 + +## - max_connect_errors +## - +## - Default: 100 (5.6.6), 10 (before) +## - +max-connect-errors = 999999 + +## - thread_concurrency +## - +## - NOTE: +## - This variable is specific to Solaris 8 and earlier systems. +## - +## - This variable is deprecated as of MySQL 5.6.1 and is removed in MySQL 5.7. +## - You should remove this from MySQL configuration files whenever you see it +## - unless they are for Solaris 8 or earlier +## - +## - (Try number of CPU's*2 for thread_concurrency) +## - +#thread-concurrency = 16 + +## - thread_cache_size +## - +## - How many threads the server should cache for reuse. When a client +## - disconnects, the client's threads are put in the cache if there are +## - fewer than thread_cache_size threads there. +## - +## - Default: 8 + (max_connections / 100) (5.6.8) , 0 (before) +## - +#thread-cache-size = 8 +thread_cache_size = 32 + +## - thread_stack +## - +## - The stack size for each thread. Many of the limits detected by +## - the crash-me test are dependent on this value. +## - +## - The default of 192KB (256KB for 64-bit systems) is large enough +## - for normal operation. If the thread stack size is too small, it +## - limits the complexity of the SQL statements that the server can handle, +## - the recursion depth of stored procedures, and other memory-consuming +## - actions. +## - Default: 262144 (256K) +## - +thread-stack = 262144 + + +## - Unbenutze Datenbank Engines deaktivieren +## - + +## - skip-innodb +## - +## - Deaktiviert die Unterstützung für InnoDB +## - +## - Sincs version 5.5, you have to set default-storage-engine +## - to MyISAM, if using skip-innodb +## - +#default-storage-engine=MyISAM +#skip-innodb + + +## - log-error +## - +## - Log errors and startup messages to this file. If you omit the file +## - name, MySQL uses host_name.err. If the file name has no extension, +## - the server adds an extension of .err. +## - +log-error = $_mysql_error_log + + +## - Query Log +## - +#general-log = on +#general-log_file = $_mysql_log + + +## - ft_min_word_len +## - +## - Die minimale Länge des Wortes, das in einem FULLTEXT-Index enthalten sein darf. +## - +## - Notice! +## - if you set +## - [mysqld] +## - ft_min_word_len=3 +## - +## - you should also set +## - [myisamchk] +## - ft_min_word_len=3 +## - +## - +## - Vorgabewert ist 4 +#ft-min-word-len = 3 + +## - ft_stopword_file +## - +## - Datei, aus der die Liste der Stoppwörter für die Volltextsuche ausgelesen wird. +## - Es werden alle Wörter aus der Datei verwendet; Kommentare hingegen werden nicht +## - berücksichtigt. Standardmäßig wird eine eingebaute Liste mit Stoppwörtern (wie +## - in der Datei myisam/ft_static.c definiert) verwendet. Wird diesee Variable auf den +## - Leer-String gesetzt (''), wird die Ausfilterung von Stoppwörtern deaktiviert. +## - +## - Hinweis: Wird diese Variable geändern oder den Inhalt der Stoppwortdatei selbst, +## - müssen die FULLTEXT-Indizes neu erstellt werden (REPAIR TABLE tbl_name QUICK. ). +## - +#ft-stopword-file = /usr/local/mysql/stopwords_utf8_iso8859-15.txt + + + +## ------------- +## - query cache + + +## - query_cache_type +## - +## - 0 : verhindert das Speichern von Abfragen im und +## - das Abrufen aus dem Cache +## - 1 : gestattet das Speichern von Abfragen im Cache. +## - Ausgenommen sind Anweisungen, die mit +## - SELECT SQL_NO_CACHE beginnen. +## - 2 : speichert nur diejenigen Anweisungen im Cache, +## - die mit SELECT SQL_CACHE beginnen. +EOF + if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +## - +## - Removed since MySQL Version 8.0.3 +## - +#query_cache_type = 1 +EOF + else + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +query_cache_type = 1 +EOF + fi + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf + + +## - query_cache_limit +## - +## - Gibt die maximale Größe einzelner Abfrageergebnisse an, die im +## - Cache gespeichert werden können. +## - +## - Vorgeabewert ist 1Mbyte +## - +EOF + if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +## - +## - Removed since MySQL Version 8.0.3 +## - +#query-cache-limit = 4M +EOF + else + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +#query-cache-limit = 4M +query_cache_limit = 16M +EOF + fi + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf + + +## - query_cache_min_res_unit +## - +## - Die im Abfrage-Cache abgelegten Ergebnisse, werden nicht am Stück +## - verwaltet. Der Abfrage-Cache reserviert Blöcke zur Speicherung dieser +## - Daten nach Bedarf, d. h. wenn ein Block voll ist, wird der nächste +## - zugewiesen. Da der Speicherreservierungsvorgang (in zeitlicher Hinsicht) +## - aufwändig ist, reserviert der Abfrage-Cache die Blöcke mit einer +## - Mindestgröße, die durch die Systemvariable query_cache_min_res_unit +## - festgelegt wird. Wird eine Abfrage ausgeführt, dann wird der letzte +## - Ergebnisblock auf die tatsächliche Datengröße zugeschnitten, sodass +## - unbenutzter Speicher freigegeben wird. +## - +## - Siehe auch http://dev.mysql.com/doc/refman/5.1/de/query-cache-configuration.html +## - +## - Vorgabewert ist 4Kbyte +## - +EOF + if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +## - +## - Removed since MySQL Version 8.0.3 +## - +#query-cache-min-res-unit = 8K +EOF + else + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +query-cache-min-res-unit = 8K +EOF + fi + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf + + +## - query_cache_size +## - +## - Die Größe des Abfrage-Caches. +## - +## - Wird query_cache_size auf einen Wert größer Null gesetzt, so ist zu beachten, +## - dass der Abfrage-Cache eine Mindestgröße von ca. 40 Kbyte benötigt, um seine +## - Strukturen zuzuweisen. (Der exakte Wert hängt von der Systemarchitektur ab.) +## - Wird der Wert zu niedrig angesetzt, wird eine Warnung ausgegeben. +## - +## - Vorgabewert ist 0, d. h. der Abfrage-Cache ist vorgabeseitig deaktiviert. +## - +EOF + if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +## - +## - Removed since MySQL Version 8.0.3 +## - +#query-cache-size = 128M +#query_cache_size = 512M +#query_cache_size = 1024M +EOF + else + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +#query-cache-size = 128M +#query_cache_size = 512M +query_cache_size = 1024M +EOF + fi + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf + +## - query cache +## ------------- + + +## -------------- +## - slow queries + +## - slow_query_log +## - +## - Gibt an, ob das Logging für langsame Abfragen eingeschaltet (1 oder ON) +## - bzw ausgeschaltet (0 oder OFF) ist. +## - +## - Vorgabewert ist 0 oder OFF +## - +slow-query-log = 1 + + +## - long_query_time +## - +## - Wenn eine Abfrage länger dauert als durch diese Variable (in Sekunden) angegeben, +## - erhöht der Server die Statusvariable Slow_queries entsprechend. Wird die Option +## - --log-slow-queries verwendet, wird die Abfrage in der Logdatei für langsame Abfragen +## - protokolliert. Dieser Wert wird als Echtzeit (nicht als Prozessorzeit) gemessen, d. h. +## - eine Abfrage, die bei einem System mit geringer Belastung den Schwellwert +## - unterschreitet, kann bei einem stark belasteten System bereits darüber liegen. +## - Der Mindestwert ist 1. +## - +## - Vorgabewert ist 10 +## - +long-query-time = 1 + + +## - slow_query_log_file +## - +## - Name der Logdatei, in die langsame Abfragen gespeichert werden. +## - +## - Vorgabewert ist -slow.log +## - +slow-query-log-file = $_mysql_slow_query_log + + +## - log-queries-not-using-indexes +## - +## - Gibt an, ob Abfragen, die keine Indizes benutzen in der Logdatei +## - für langsame Abfragen mitgespeichert werden sollen. +## - +## - Vorgabewert ist 0 +## - +#log-queries-not-using-indexes = 1 +log-queries-not-using-indexes = 0 + +## - slow queries +## -------------- + +## - join_buffer_size +## - +## - Die Größe des Puffers, der für Joins benutzt wird, die keine Indizes verwenden +## - und deswegen vollständige Tabellenscans durchführen. Normalerweise besteht die +## - beste Möglichkeit der Realisierung schneller Joins darin, Indizes hinzuzufügen. +## - Erhöhen Sie den Wert von join_buffer_size, um einen schnelleren vollständigen +## - Join zu implementieren, wenn das Hinzufügen von Indizes nicht möglich ist. Für +## - jeden vollständigen Join zwischen zwei Tabellen wird ein Join-Puffer hinzugefügt. +## - Für einen komplexen Join zwischen mehreren Tabellen, für den Indizes nicht verwendet +## - werden, sind unter Umständen mehrere Join-Puffer erforderlich. +## - +## - Wird die Option --log-slow-queries (ON) verwendet, werden Abfragen, die keine +## - Indizes verwenden, in das Log für langsame Abfragen geschrieben. +## - +## - Vorgabewert ist 128K +## - +#join-buffer-size = 384K +#join_buffer_size = 768K +#join_buffer_size = 1024K +join_buffer_size = 1536K + + + +## - max_heap_table_size +## - +## - Diese Variable bestimmt die maximale Größe, auf die MEMORY-Tabellen anwachsen dürfen. +## - Der Wert der Variable wird zur Berechnung von MAX_ROWS-Werte für MEMORY-Tabellen +## - verwendet. Die Einstellung der Variable hat keine Auswirkungen auf bereits vorhandene +## - MEMORY-Tabellen, sofern diese nicht mit einer Anweisung wie CREATE TABLE neu erstellt +## - oder mit ALTER TABLE oder TRUNCATE TABLE modifiziert werden. +## - +## - Vorgabewert ist 16Mbyte +## - +#max-heap-table-size = 96M +#max_heap_table_size = 128M +#max_heap_table_size = 768M +#max_heap_table_size = 1024M +max_heap_table_size = 2048M + + +## - tmp_table_size +## - +## - Überschreitet eine temporäre Tabelle im Arbeitsspeicher diese Größe, wandelt MySQL +## - sie automatisch in eine MyISAM-Tabelle auf der Festplatte um. +## - +## - Werden viele erweiterte GROUP-BY-Anfragen ausgeführt (und ist genügend Speicher +## - vorhanden), so sollte diese Variable erhöht werden. +## +## - Default: 16777216 (16M) +## - +## - Note: +## - Effective in-memory tmp_table_size is limited to max_heap_table_size. +## - +#tmp-table-size = 96M +#tmp_table_size = 768M +tmp_table_size = 2048M + + + +## - angepasste Einstellungen +## ------------------------------------------ + + +# This group is only read by MariaDB servers, not by MySQL. +# If you use the same .cnf file for MySQL and MariaDB, +# you can put MariaDB-only options here +[mariadb] + +## - innodb_purge_threads +## - +## - Number of background threads dedicated to InnoDB purge operations. The range +## - is 1 to 32. At least one background thread is always used from MariaDB 10.0. +## - +## - The default has been increased from 1 to 4 in MariaDB 10.2.2. Setting to a +## - value greater than 1 creates that many separate purge threads. This can improve +## - efficiency in some cases, such as when performing DML operations on many tables. +## - In MariaDB 5.5, the options are 0 and 1. If set to 0, the default, purging is +## - done with the primary thread. If set to 1, purging is done on a separate thread, +## - which could reduce contention. See also innodb_purge_batch_size. +## - +## - Default Value: +## - +## - 4 (>= MariaDB 10.2.2) +## - 1 (>=MariaDB 10.0 to <= MariaDB 10.2.1) +#innodb_purge_threads = 4 + + +## ------------- +## - query cache + +## - query_cache_type +## - +## - 0 : verhindert das Speichern von Abfragen im und +## - das Abrufen aus dem Cache +## - 1 : gestattet das Speichern von Abfragen im Cache. +## - Ausgenommen sind Anweisungen, die mit +## - SELECT SQL_NO_CACHE beginnen. +## - 2 : speichert nur diejenigen Anweisungen im Cache, +## - die mit SELECT SQL_CACHE beginnen. +## - +## - Removed since MySQL Version 8.0.3 +## - +## - But present at MariaDB +## - +#query_cache_type = 1 +query_cache_type = 0 + + +## - query_cache_limit +## - +## - Gibt die maximale Größe einzelner Abfrageergebnisse an, die im +## - Cache gespeichert werden können. +## - +## - Vorgeabewert ist 1Mbyte +## - +## - Removed since MySQL Version 8.0.3 +## - +## - But present at MariaDB +## - +#query-cache-limit = 4M +query_cache_limit = 128M + + +## - query_cache_min_res_unit +## - +## - Die im Abfrage-Cache abgelegten Ergebnisse, werden nicht am Stück +## - verwaltet. Der Abfrage-Cache reserviert Blöcke zur Speicherung dieser +## - Daten nach Bedarf, d. h. wenn ein Block voll ist, wird der nächste +## - zugewiesen. Da der Speicherreservierungsvorgang (in zeitlicher Hinsicht) +## - aufwändig ist, reserviert der Abfrage-Cache die Blöcke mit einer +## - Mindestgröße, die durch die Systemvariable query_cache_min_res_unit +## - festgelegt wird. Wird eine Abfrage ausgeführt, dann wird der letzte +## - Ergebnisblock auf die tatsächliche Datengröße zugeschnitten, sodass +## - unbenutzter Speicher freigegeben wird. +## - +## - Siehe auch http://dev.mysql.com/doc/refman/5.1/de/query-cache-configuration.html +## - +## - Vorgabewert ist 4Kbyte +## - +## - +## - Removed since MySQL Version 8.0.3 +## - +## - But present at MariaDB +## - +#query_cache_min_res_unit = 8K + + +## - query_cache_size +## - +## - Die Größe des Abfrage-Caches. +## - +## - Wird query_cache_size auf einen Wert größer Null gesetzt, so ist zu beachten, +## - dass der Abfrage-Cache eine Mindestgröße von ca. 40 Kbyte benötigt, um seine +## - Strukturen zuzuweisen. (Der exakte Wert hängt von der Systemarchitektur ab.) +## - Wird der Wert zu niedrig angesetzt, wird eine Warnung ausgegeben. +## - +## - Vorgabewert ist 1Mbyte, d. h. der Abfrage-Cache ist vorgabeseitig deaktiviert. +## - +## - +## - Removed since MySQL Version 8.0.3 +## - +## - But present at MariaDB +## - +query_cache_size = 128M + +## - query cache +## ------------- + +# This group is only read by MariaDB-10.3 servers. +# If you use the same .cnf file for MariaDB of different versions, +# use this group for options that older servers don't understand +[mariadb-10.3] + + +[mariadb-10.4] + + +[mariadb-10.6] + +## - innodb_read_only_compressed +## - +## - Make ROW_FORMAT=COMPRESSED tables read-only (ON by default) +## - +innodb_read_only_compressed = OFF + + +[mysqldump] +quick +max-allowed-packet = 1024M +default-character-set = utf8mb4 + + +[mysql] +no-auto-rehash +# Remove the next comment character if you are not familiar with SQL +#safe-updates +local-infile = 1 + + +[myisamchk] +key-buffer-size = 256M +sort-buffer-size = 256M +read-buffer = 2M +write-buffer = 2M + + +## ------------------------------------------ +## - angepasste Einstellungen + +## - ft_min_word_len +## - +## - Die minimale Länge des Wortes, das in einem FULLTEXT-Index enthalten sein darf. +## - +## - Notice! +## - if you set +## - [mysqld] +## - ft_min_word_len=3 +## - +## - you should also set +## - [myisamchk] +## - ft_min_word_len=3 +## - +## - +## - Vorgabewert ist 4 +#ft-min-word-len = 3 + +## - angepasste Einstellungen +## ------------------------------------------ + + +[mysqlhotcopy] +interactive-timeout + + +EOF + if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +## - sql_mode +## - +## - Since Version 8.0.11 NO_AUTO_CREATE_USER is no longer available +## - +## - For now, we will use the default value, it seems to be ok. +## - +#sql-mode = "ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" +EOF + + else + cat << EOF >> ${MYSQL_INSTALL_DIR}/etc/my.cnf +## - sql_mode +## - +## - To be compartible with older programming on mysql 5.6 +## - +#sql-mode = "ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" + +EOF + fi + + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Konnte Konfigurationsdatei \"${MYSQL_INSTALL_DIR}/etc/my.cnf\" nicht erstellen.. + fi + + if [[ -f "${MYSQL_INSTALL_DIR}/my.cnf" ]]; then + echononl "Backup existing file '${MYSQL_INSTALL_DIR}/my.cnf'.." + echo "" >> ${logdir}/main.log + echo "## - Backup existing file '${MYSQL_INSTALL_DIR}/my.cnf'.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mv \"${MYSQL_INSTALL_DIR}/my.cnf\" \"${MYSQL_INSTALL_DIR}/my.cnf.ORIG\"" >> ${logdir}/main.log + mv "${MYSQL_INSTALL_DIR}/my.cnf" "${MYSQL_INSTALL_DIR}/my.cnf.ORIG" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Kann datei '${MYSQL_INSTALL_DIR}/my.cnf' nicht sichern!" + fi + fi + + echononl "Erstelle Symlink ${MYSQL_INSTALL_DIR}/my.cnf --> ${MYSQL_INSTALL_DIR}/etc/my.cnf" + echo "" >> ${logdir}/main.log + echo "## - Erstelle Symlink ${MYSQL_INSTALL_DIR}/my.cnf --> ${MYSQL_INSTALL_DIR}/etc/my.cnf" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "ln -s \"etc/my.cnf\" \"${MYSQL_INSTALL_DIR}/my.cnf\"" >> ${logdir}/main.log + ln -s "etc/my.cnf" "${MYSQL_INSTALL_DIR}/my.cnf" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Kann Symlink ${MYSQL_INSTALL_DIR}/my.cnf --> ${MYSQL_INSTALL_DIR}/etc/my.cnf nicht erstellen!" + fi + +fi + +if [[ ! -d "/etc/mysql" ]]; then + + echononl "Erstelle Verzeichnis '/etc/mysql' .." + echo "" >> ${logdir}/main.log + echo "## - Erstelle Verzeichnis '/etc/mysql' .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mkdir \"/etc/mysql\"" >> ${logdir}/main.log + mkdir "/etc/mysql" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Konnte Verzeichnis '/etc/mysql' nicht erstellen" + fi + +else + + if [[ -f "/etc/mysql/my.cnf" ]]; then + echononl "Backup Symlink/Datei '/etc/mysql/my.cnf' .." + echo "" >> ${logdir}/main.log + echo "## - Backup Symlink/Datei '/etc/mysql/my.cnf' .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mv \"/etc/mysql/my.cnf\" \"/etc/mysql/my.cnf.${_backup_date}\"" >> ${logdir}/main.log + mv "/etc/mysql/my.cnf" "/etc/mysql/my.cnf.${_backup_date}" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Konnte Symlink/Datei '/etc/mysql/my.cnf' nicht sichern." + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + fi + +fi + +echononl "Add Path '$(dirname "${MYSQL_INSTALL_DIR}")/mysql/etc/my.cnf' for 'my.cnf' using 'update-alternatives'.." +if ! $PARALLEL_INSTALLATION ; then + + if $(update-alternatives --list my.cnf 2>/dev/null | grep -q $(dirname "${MYSQL_INSTALL_DIR}")/mysql/etc/my.cnf 2>/dev/null) ; then + echo_skipped + else + + echo "" >> ${logdir}/main.log + echo "## - Add Path '$(dirname "${MYSQL_INSTALL_DIR}")/mysql/etc/my.cnf' for 'my.cnf' using 'update-alternatives'.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "update-alternatives --install /etc/mysql/my.cnf my.cnf $(dirname "${MYSQL_INSTALL_DIR}")/mysql/etc/my.cnf 300" >> ${logdir}/main.log + update-alternatives --install /etc/mysql/my.cnf my.cnf $(dirname "${MYSQL_INSTALL_DIR}")/mysql/etc/my.cnf 1300 >> ${logdir}/main.log 2>&1 + + if [ "$?" = "0" ]; then + echo_ok + + echononl "Set link '/etc/alternatives/my.cnf' using 'update-alternatives'..." + echo "" >> ${logdir}/main.log + echo "## - Set link '/etc/alternatives/my.cnf' using 'update-alternatives'..." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "update-alternatives --set my.cnf $(dirname "${MYSQL_INSTALL_DIR}")/mysql/etc/my.cnf" >> ${logdir}/main.log + + update-alternatives --set my.cnf $(dirname "${MYSQL_INSTALL_DIR}")/mysql/etc/my.cnf + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Setting link '/etc/alternatives/my.cnf using 'update-alternatives' mechanism failed!" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + + fi + + else + echo_failed + error "Adding PATH '$(dirname "${MYSQL_INSTALL_DIR}")/mysql/etc/my.cnf' for Link '/etc/alternatives/my.cnf' using 'update-alternatives' mechanism failed!" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + fi + +else + echo_skipped +fi # if ! $PARALLEL_INSTALLATION ; then + + + +#echononl "Erstelle Symlink /etc/mysql/my.cnf --> ${MYSQL_INSTALL_DIR}/etc/my.cnf" +#if ! $PARALLEL_INSTALLATION ; then +# +# echo "" >> ${logdir}/main.log +# echo "## - Erstelle Symlink /etc/mysql/my.cnf --> ${MYSQL_INSTALL_DIR}/etc/my.cnf" >> ${logdir}/main.log +# echo "## -" >> ${logdir}/main.log +# echo "ln -s \"$(dirname "${MYSQL_INSTALL_DIR}")/mysql/etc/my.cnf\" \"/etc/mysql/\"" >> ${logdir}/main.log +# ln -s "$(dirname "${MYSQL_INSTALL_DIR}")/mysql/etc/my.cnf" "/etc/mysql/my.cnf" >> ${logdir}/main.log 2>&1 +# if [ "$?" = "0" ]; then +# echo_ok +# else +# echo_failed +# error "Konnte Symlink /etc/mysql/my.cnf --> ${MYSQL_INSTALL_DIR}/etc/my.cnf nicht erstellen." +# +# echononl "continue anyway [yes/no]: " +# read OK +# OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" +# while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do +# echononl "Wrong entry! - repeat [yes/nno]: " +# read OK +# done +# [[ $OK = "yes" ]] || fatal "Abbruch durch User" +# fi +# +#else +# echo_skipped +#fi # if ! $PARALLEL_INSTALLATION ; then + + +echononl "Kopiere 'stopwords_utf8_iso8859-15.txt' -> ${MYSQL_INSTALL_DIR}.." +if [ -f "${MYSQL_SRC_BASE_DIR}/stopwords_utf8_iso8859-15.txt" ];then + echo "" >> ${logdir}/main.log + echo "## - Kopiere 'stopwords_utf8_iso8859-15.txt' -> ${MYSQL_INSTALL_DIR}" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "cp ${MYSQL_SRC_BASE_DIR}/stopwords_utf8_iso8859-15.txt ${MYSQL_INSTALL_DIR}" >> ${logdir}/main.log + + cp ${MYSQL_SRC_BASE_DIR}/stopwords_utf8_iso8859-15.txt ${MYSQL_INSTALL_DIR} + if [ "$?" = "0" ]; then + echo_ok + + echononl "Aktiviere Stopword Datei.." + if ! grep -q -E "^\s*ft_stopword_file.*" "${MYSQL_INSTALL_DIR}/etc/my.cnf" 2> /dev/null ; then + echo "" >> ${logdir}/main.log + echo "## - Aktiviere Stopword Datei" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s/^(\s*#\s*)(ft_stopword_file.*)/#\1\2\n\2/\" ${MYSQL_INSTALL_DIR}/etc/my.cnf" >> ${logdir}/main.log + perl -i -n -p -e "s/^(\s*#\s*)(ft_stopword_file.*)/#\1\2\n\2/" ${MYSQL_INSTALL_DIR}/etc/my.cnf >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Konnte Stopword Datei \"stopwords_utf8_iso8859-15.txt\" nicht aktivieren." + fi + else + echo_skipped + fi + + else + echo_failed + warn "Konnte stopwords_utf8_iso8859-15.txt nicht nach ${MYSQL_INSTALL_DIR} kopieren" + fi +else + echo_skipped + warn "Konnte ${MYSQL_SRC_BASE_DIR}/stopwords_utf8_iso8859-15.txt finden." +fi + + +if $UPDATE_MYSQL && ! $PARALLEL_INSTALLATION ; then + + ## ----- + ## - Stoppe MySQL Datenbank Service + ## ----- + + echo "" + echo "" + echo -e "\033[37m\033[1mStoppe MySQL Datenbank Service\033[m" + echo "" + + echo "" >> ${logdir}/main.log + echo "" >> ${logdir}/main.log + echo "## -----" >> ${logdir}/main.log + echo "## - Stoppe MySQL Datenbank Service" >> ${logdir}/main.log + echo "## -----" >> ${logdir}/main.log + + echononl "Stoppe MySQL Datenbankserver.." + echo "" >> ${logdir}/main.log + echo "## - Stoppe MySQL Datenbankserver" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + if $INSTALL_SYSTEMD_SERVICE ; then + + _found_mysql_processes=false + + echo "systemctl stop \"$MYSQL_SERVICE_FILE\"" >> ${logdir}/main.log + systemctl stop "$MYSQL_SERVICE_FILE" >> ${logdir}/main.log 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + + _pid_string="${MYSQL_CUR_DISTRIBUTION,,}-${CURRENT_VERSION}/bin/(mysqld_safe |mysqld )" + PIDS="$(ps aux | grep -E "$_pid_string" | grep -v grep | awk '{print$2}')" + + if [[ "X${PIDS}X" != "XX" ]];then + + _found_mysql_processes=true + echo_failed + + error "Konnte MySQL Datenbankserver nicht stoppen - Some old mysql processs seams to be running\n\n \\033[1mStop MySQL manually ! \033[m" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + + fi + + _pid_string="${MYSQL_INSTALL_DIR}/bin/(mysqld_safe |mysqld )" + PIDS="$(ps aux | grep -E "$_pid_string" | grep -v grep | awk '{print$2}')" + + if [[ "X${PIDS}X" != "XX" ]];then + + _found_mysql_processes=true + echo_failed + + error "Konnte MySQL Datenbankserver nicht stoppen - Some mysql processs seams to be running\n\n \\033[1mStop MySQL manually ! \033[m" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + + fi + + if ! $_found_mysql_processes ; then + echo_ok + fi + + + fi + else + if $SYSTEMD_EXISTS ; then + echo "systemctl stop ${MYSQL_SYSV_INIT_SCRIPT}" >> ${logdir}/main.log + systemctl stop ${MYSQL_SYSV_INIT_SCRIPT} >> ${logdir}/main.log 2>&1 + else + echo "/etc/init.d/${MYSQL_SYSV_INIT_SCRIPT} stop" >> ${logdir}/main.log + /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT} stop >> ${logdir}/main.log 2>&1 + fi + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Konnte MySQL Datenbankserver nicht stoppen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + + fi + fi + + echononl "Sleep for 5 seconds.." + echo_wait + sleep 5 + echo_ok + + echo "" + +fi + +if $INSTALL_SYSTEMD_SERVICE ; then + + echononl "Kopiere Service File nach '/etc/systemd/system'.." + echo "" >> ${logdir}/main.log + echo "## - Kopiere Service File nach '/etc/systemd/system'" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + + if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]]; then + echo "cp \"${MYSQL_INSTALL_DIR}/support-files/systemd/mariadb.service\" /etc/systemd/system/$MYSQL_SERVICE_FILE" >> ${logdir}/main.log + cp "${MYSQL_INSTALL_DIR}/support-files/systemd/mariadb.service" "/etc/systemd/system/$MYSQL_SERVICE_FILE" >> ${logdir}/main.log 2>&1 + _retval=$? + else + echo "cp \"${MYSQL_INSTALL_DIR}/lib/systemd/system/mysqld.service\" /etc/systemd/system/$MYSQL_SERVICE_FILE" >> ${logdir}/main.log + cp "${MYSQL_INSTALL_DIR}/lib/systemd/system/mysqld.service" "/etc/systemd/system/$MYSQL_SERVICE_FILE" >> ${logdir}/main.log 2>&1 + _retval=$? + fi + + if [[ $_retval -eq 0 ]]; then + echo_ok + else + echo_failed + error "Kopieren Service File nach '/etc/systemd/system/${MYSQL_SERVICE_FILE}' failed!" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]]; then + if ! $PARALLEL_INSTALLATION ; then + echononl "Erstelle Verzeichnis '/etc/systemd/system/${MYSQL_SERVICE_FILE}.d'.." + if [[ ! -d "/etc/systemd/system/${MYSQL_SERVICE_FILE}.d" ]] ; then + + echo "" >> ${logdir}/main.log + echo "## - Erstelle Verzeichnis '/etc/systemd/system/${MYSQL_SERVICE_FILE}.d'" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mkdir \"/etc/systemd/system/${MYSQL_SERVICE_FILE}.d\"" >> ${logdir}/main.log + + mkdir "/etc/systemd/system/${MYSQL_SERVICE_FILE}.d" >> ${logdir}/main.log 2>&1 + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "Creating directory '/etc/systemd/system/${MYSQL_SERVICE_FILE}.d' failed!" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + else + echo_skipped + fi + + echononl "Erstelle Datei '/etc/systemd/system/${MYSQL_SERVICE_FILE}.d/set-alias.conf'" + echo "" >> ${logdir}/main.log + echo "## - Erstelle Datei '/etc/systemd/system/${MYSQL_SERVICE_FILE}.d/set-alias.conf'" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + + echo "cat < \"/etc/systemd/system/${MYSQL_SERVICE_FILE}.d/set-alias.conf\" +[Install] +Alias=mysqld.service mysql.service +EOF +" >> ${logdir}/main.log + + cat < "/etc/systemd/system/${MYSQL_SERVICE_FILE}.d/set-alias.conf" +[Install] +Alias=mysqld.service mysql.service +EOF + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "Creating file '/etc/systemd/system/${MYSQL_SERVICE_FILE}.d/set-alias.conf' failed!" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + fi #if ! $UPDATE_MYSQL && ! $PARALLEL_INSTALLATION ; then + fi # if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]]; then + + + echononl "Add '--defaults-file=..' to ExecStart command line at systemd service file.." + echo "" >> ${logdir}/main.log + echo "## - Add '--defaults-file=..' to ExecStart command line at systemd service file.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s&^(\s*ExecStart=[^\s]+)\s+(.*)&\1 --defaults-file=${MYSQL_INSTALL_DIR}/etc/my.cnf \2&\" /etc/systemd/system/$MYSQL_SERVICE_FILE" >> ${logdir}/main.log + + perl -i -n -p -e "s&^(\s*ExecStart=[^\s]+)\s+(.*)&\1 --defaults-file=${MYSQL_INSTALL_DIR}/etc/my.cnf \2&" \ + /etc/systemd/system/$MYSQL_SERVICE_FILE >> ${logdir}/main.log + if [[ $_retval -eq 0 ]]; then + echo_ok + else + echo_failed + error "Modifiing ExecStart command line at '/etc/systemd/system/${MYSQL_SERVICE_FILE}' failed!" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + + echononl "Set open_files_limit (LimitNOFILE) to $(ulimit -Hn) .." + echo "" >> ${logdir}/main.log + echo "## - Set open_files_limit (LimitNOFILE) to $(ulimit -Hn) .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + + if grep -q -E "^\s*LimitNOFILE\s*=" /etc/systemd/system/$MYSQL_SERVICE_FILE ; then + echo "perl -i -n -p -e \"s/^(\s*LimitNOFILE\s*=.*)/#\1\nLimitNOFILE = $(ulimit -Hn)/\" /etc/systemd/system/$MYSQL_SERVICE_FILE" >> ${logdir}/main.log + perl -i -n -p -e "s/^(\s*LimitNOFILE\s*=.*)/#\1\nLimitNOFILE = $(ulimit -Hn)/" \ + /etc/systemd/system/$MYSQL_SERVICE_FILE >> ${logdir}/main.log 2>&1 + _retval=$? + else + echo "LimitNOFILE = $(ulimit -Hn)" >> /etc/systemd/system/$MYSQL_SERVICE_FILE + _retval=$? + fi + if [ "$_retval" = "0" ]; then + echo_ok + else + echo_failed + error "Setting open_files_limit (LimitNOFILE) to $(ulimit -Hn) failed!" + fi + + echononl "Create environmet file '${SYSTEMD_ENV_FILE}' for systemd service.." + echo "" >> ${logdir}/main.log + echo "## - Create environmet file '${SYSTEMD_ENV_FILE}' for systemd service.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "cat < $SYSTEMD_ENV_FILE +MYSQL_HOME=\"$MYSQL_INSTALL_DIR\" +EOF +" >> ${logdir}/main.log + cat < $SYSTEMD_ENV_FILE +MYSQL_HOME="$MYSQL_INSTALL_DIR" +EOF + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "Creating environmet file fo systemd service failed!" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + echononl "Add/Replace 'EnvironmentFile' variable at service file .." + echo "" >> ${logdir}/main.log + echo "## - Add/Replace 'EnvironmentFile' variable at service file .." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + + if grep -q -E "^\s*EnvironmentFile\s*=" /etc/systemd/system/$MYSQL_SERVICE_FILE ; then + echo "perl -i -n -p -e \"s#^(\s*EnvironmentFile\s*=.*)#\#\1\nEnvironmentFile=-${SYSTEMD_ENV_FILE}#\" /etc/systemd/system/$MYSQL_SERVICE_FILE" >> ${logdir}/main.log + perl -i -n -p -e "s#^(\s*EnvironmentFile\s*=.*)#\#\1\nEnvironmentFile=-${SYSTEMD_ENV_FILE}#" \ + /etc/systemd/system/$MYSQL_SERVICE_FILE >> ${logdir}/main.log 2>&1 + _retval=$? + else + echo "cat <> /etc/systemd/system/$MYSQL_SERVICE_FILE + +EnvironmentFile=-$SYSTEMD_ENV_FILE +EOF" >> ${logdir}/main.log 2>&1 + cat <> /etc/systemd/system/$MYSQL_SERVICE_FILE 2>> ${logdir}/main.log + +EnvironmentFile=-$SYSTEMD_ENV_FILE +EOF + _retval=$? + fi + if [ "$_retval" = "0" ]; then + echo_ok + else + echo_failed + error "Adding/Replacing 'EnvironmentFile' variable at service file failed!" + fi + + if $PARALLEL_INSTALLATION ; then + + + if grep -q -E "^\s*Alias\s*=" /etc/systemd/system/$MYSQL_SERVICE_FILE ; then + echononl "Disable 'Alias' directive(s) at service file.." + echo "" >> ${logdir}/main.log + echo "## - Disable 'Alias' directive(s) at service file.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s/^(\s*Alias\s*=.*)/#\1/\" /etc/systemd/system/$MYSQL_SERVICE_FILE" >> ${logdir}/main.log + perl -i -n -p -e "s/^(\s*Alias\s*=.*)/#\1/" /etc/systemd/system/$MYSQL_SERVICE_FILE >> ${logdir}/main.log 2>&1 + + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Disbling 'Alias' directive(s) at service file failed!" + fi + fi + + fi # if $PARALLEL_INSTALLATION ; then + + echononl "Aktiviere den MySQL Datenbank Service für den automatischem Start.." + echo "" >> ${logdir}/main.log + echo "## - Aktiviere den MySQL Datenban Service für den automatischem Start" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "systemctl enable $MYSQL_SERVICE_FILE" >> ${logdir}/main.log + systemctl enable $MYSQL_SERVICE_FILE >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Aktivieren des MySQL Datenbank Service für den automatischem Start fehgeschalgen!" + fi + + echononl "Run 'systemctl daemon-reload' to reload units." + echo "" >> ${logdir}/main.log + echo "## - Run 'systemctl daemon-reload' to reload units." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "systemctl daemon-reload" >> ${logdir}/main.log + systemctl daemon-reload >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Run 'systemctl daemon-reload' failed!" + fi + + +else + + if [ -h "/etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}" ]; then + echononl "Entferne vorhandenen Symlink \"/etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}\".." + echo "" >> ${logdir}/main.log + echo "## - Entferne vorhandenen Symlink \"/etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}\"" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "rm /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}" >> ${logdir}/main.log + rm /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT} >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Kann Symlink /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT} nicht entfernen.. + fi + fi + + if [ -f "/etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}" ]; then + echononl "Entferne vorhandenen Datei \"/etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}\".." + echo "" >> ${logdir}/main.log + echo "## - Entferne vorhandenen Datei \"/etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}\"" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "rm /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}" >> ${logdir}/main.log + rm /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT} >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Kann Datei /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT} nicht entfernen.. + fi + fi + + + echononl "Erstelle Symlink \"/etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}\".." + echo "" >> ${logdir}/main.log + echo "## - Erstelle Symlink \"/etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}\"" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + + if $PARALLEL_INSTALLATION ; then + echo "ln -s \"${MYSQL_INSTALL_DIR}/support-files/${SUPPORT_FILE_INIT_SCRIPT}\" \"/etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}\"" >> ${logdir}/main.log + ln -s "${MYSQL_INSTALL_DIR}/support-files/${SUPPORT_FILE_INIT_SCRIPT}" /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT} >> ${logdir}/main.log 2>&1 + else + echo "ln -s \"$(dirname $MYSQL_INSTALL_DIR)/mysql/support-files/${MYSQL_SYSV_INIT_SCRIPT}\" \"/etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}\"" >> ${logdir}/main.log + ln -s "$(dirname $MYSQL_INSTALL_DIR)/mysql/support-files/${MYSQL_SYSV_INIT_SCRIPT}" /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT} >> ${logdir}/main.log 2>&1 + fi + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Kann Symlink $MYSQL_INSTALL_DIR/support-files/${MYSQL_SYSV_INIT_SCRIPT} --> /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT} nicht erstellen.." + fi + + echononl "Setze ulimit im Startscript.." + echo "" >> ${logdir}/main.log + echo "## - Setze ulimit im Startscript" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "sed -i \"1 s/\(.*\)/\1\n\nulimit -n \\\`ulimit -Hn\\\`\n/\" /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}" >> ${logdir}/main.log + sed -i "1 s/\(.*\)/\1\n\nulimit -n \`ulimit -Hn\`\n/" $(realpath /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT}) >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Kann \"ulimit\" im Startscript nicht setzen /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT} nicht setzen.." + fi + + echononl "Aktiviere den MySQL Datenbank Service für den automatischem Start" + echo "" >> ${logdir}/main.log + echo "## - Aktiviere den MySQL Datenbank Service für den automatischem Start" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + if $SYSTEMD_EXISTS ; then + echo "systemctl enable ${MYSQL_SYSV_INIT_SCRIPT}" >> ${logdir}/main.log + systemctl enable ${MYSQL_SYSV_INIT_SCRIPT} >> ${logdir}/main.log 2>&1 + else + echo "update-rc.d ${MYSQL_SYSV_INIT_SCRIPT} defaults" >> ${logdir}/main.log + update-rc.d ${MYSQL_SYSV_INIT_SCRIPT} defaults >> ${logdir}/main.log 2>&1 + fi + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + if $SYSTEMD_EXISTS ; then + error "Konnte \"${MYSQL_SYSV_INIT_SCRIPT}\" im systemd nicht aktivieren.." + else + error "Konnte MySQL Run Level Links (autom. boot) nicht erstellen.." + fi + fi + + echononl "Run 'systemctl daemon-reload' to reload units." + if $SYSTEMD_EXISTS ; then + echo "" >> ${logdir}/main.log + echo "## - Run 'systemctl daemon-reload' to reload units." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "systemctl daemon-reload" >> ${logdir}/main.log + systemctl daemon-reload >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Run 'systemctl daemon-reload' failed!" + fi + else + echo_skipped + fi + +fi + +echo "" +echononl "Erstelle MySQL Run-Verzeichnis '$MYSQL_RUN_DIR'.." +if [[ ! -d "${MYSQL_RUN_DIR}" ]] ; then + + echo "" >> ${logdir}/main.log + echo "## - Erstelle MySQL Run-Verzeichnis '$MYSQL_RUN_DIR'.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "mkdir $MYSQL_RUN_DIR" >> ${logdir}/main.log + mkdir $MYSQL_RUN_DIR >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Kann MySQL Run-Verzeichnis \"${MYSQL_RUN_DIR}\" nicht erstellen.." + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + + fi + + echononl "Setze Besitzer \"${MYSQL_USER}:${MYSQL_GROUP}\" für Run-Verzeichnis" + echo "" >> ${logdir}/main.log + echo "## - Setze Besitzer \"${MYSQL_USER}:${MYSQL_GROUP}\" für Run-Verzeichnis" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "chown ${MYSQL_USER}:${MYSQL_GROUP} ${MYSQL_RUN_DIR}" >> ${logdir}/main.log + chown ${MYSQL_USER}:${MYSQL_GROUP} ${MYSQL_RUN_DIR} >> ${logdir}/main.log 2>&1 + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "Kann Besitzer für das MySQL Run-Verzeichnis \"${MYSQL_RUN_DIR}\" nicht ändern.." + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + +else + echo_skipped +fi + + +## ----- +## - Starte MySQL Datenbank Service +## ----- + + +echo "" +echo "" +echo -e "\033[37m\033[1mStarte MySQL Datenbank Service\033[m" +echo "" + +echo "" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log +echo "## - Starte MySQL Datenbank Service" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log + +echononl "Starte MySQL Datenbankserver.." +echo "" >> ${logdir}/main.log +echo "## - Starte MySQL Datenbankserver" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +if $INSTALL_SYSTEMD_SERVICE ; then + echo "systemctl start \"$MYSQL_SERVICE_FILE\"" >> ${logdir}/main.log + systemctl start "$MYSQL_SERVICE_FILE" >> ${logdir}/main.log 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error Konnte MySQL Datenbankserver nicht starten.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + + fi +else + if $SYSTEMD_EXISTS ; then + echo "systemctl start ${MYSQL_SYSV_INIT_SCRIPT}" >> ${logdir}/main.log + systemctl start ${MYSQL_SYSV_INIT_SCRIPT} >> ${logdir}/main.log 2>&1 + else + echo "/etc/init.d/${MYSQL_SYSV_INIT_SCRIPT} start" >> ${logdir}/main.log + /etc/init.d/${MYSQL_SYSV_INIT_SCRIPT} start >> ${logdir}/main.log 2>&1 + fi + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Konnte MySQL Datenbankserver nicht starten.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + + fi +fi + + +echononl "Sleep for 5 seconds.." +echo_wait +sleep 5 +echo_ok + + + +## ----- +## - Konfiguration ( Teil 2) MySQL Installation +## ----- + +echo "" +echo "" +echo -e "\033[37m\033[1mKonfiguration (Teil 2) der $MYSQL_DISTRIBUTION $MYSQL_VERSION Installation\033[m" +echo "" + +echo "" >> ${logdir}/main.log +echo "" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log +echo "## - Konfiguration (Teil 2) der $MYSQL_DISTRIBUTION $MYSQL_VERSION Installation" >> ${logdir}/main.log +echo "## -----" >> ${logdir}/main.log + +if ! $UPDATE_MYSQL ; then + + ## - Delete rows with empty 'User' from table mysql.user + ## - + echononl "Delete rows with empty 'User' from table mysql.user.." + echo "" >> ${logdir}/main.log + echo "## - Delete rows with empty 'User' from table mysql.user" >> ${logdir}/main.log + echo "## - " >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e \"DELETE FROM user where User = ''\"" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e "DELETE FROM user where User = ''" >> ${logdir}/main.log 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "Deleting rows with empty 'User' from table mysql.user failed!" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + ## - Drop database test + ## - + if [[ -d "${MYSQL_DATA_DIR}/test" ]]; then + echononl "Delete database 'test'.." + echo "" >> ${logdir}/main.log + echo "## - Delete database 'test'.." >> ${logdir}/main.log + echo "## - " >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e \"DROP DATABASE test\"" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e "DROP DATABASE test" >> ${logdir}/main.log 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "Deleting database 'test' failed!" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + echononl "Delete rows concerning database 'test' from table 'mysql.db'.." + echo "" >> ${logdir}/main.log + echo "## - Delete rows concerning database 'test' from table 'mysql.db'.." >> ${logdir}/main.log + echo "## - " >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e \"DELETE FROM db WHERE Db LIKE 'test%'\"" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e "DELETE FROM db WHERE Db LIKE 'test%'" >> ${logdir}/main.log 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "Deleting rows concerning database 'test' from table 'mysql.db' failed!" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + fi + + ## - Set root password + ## - + if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] \ + && [[ $MYSQL_MINOR_VERSION -ge 4 ]] ; then + + echononl "Setze root Passwort für den MySQL Zugang" + + echo "" >> ${logdir}/main.log + echo "## - Setze root Passwort für den MariaDB Zugang" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e \"ALTER USER root@localhost IDENTIFIED VIA unix_socket OR mysql_native_password USING PASSWORD('$MYSQL_ROOT_PW')\"" >> ${logdir}/main.log + + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e "ALTER USER root@localhost IDENTIFIED VIA unix_socket OR mysql_native_password USING PASSWORD('$MYSQL_ROOT_PW')" \ + >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Konnte root Passwort für den MariaDB Server nicht setzen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + ## - Flush privileges + ## - + echononl "Neu Einlesen der Berechtigung (MySQL Server).." + echo "" >> ${logdir}/main.log + echo "## - Neu Einlesen der Berechtigung (MySQL Server)" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW mysql -N -s -e \"FLUSH PRIVILEGES\"" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW mysql -N -s -e "FLUSH PRIVILEGES" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Das Laden/Erneuern der Berechtigungen für die MySQL Datenbank ist fehlgeschlagen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + elif [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] \ + || ( [[ "$MYSQL_DISTRIBUTION" = "MySQL" ]] \ + && [[ $MYSQL_MAJOR_VERSION -eq 5 ]] \ + && [[ $MYSQL_MINOR_VERSION -le 6 ]] ); then + + echononl "Setze root Passwort für den MySQL Zugang" + + echo "" >> ${logdir}/main.log + echo "## - Setze root Passwort für den MariaDB Zugang" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e \"UPDATE user SET Password = password('$MYSQL_ROOT_PW') WHERE User = 'root'\"" >> ${logdir}/main.log + + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e "UPDATE user SET Password = password('$MYSQL_ROOT_PW') WHERE User = 'root'" \ + >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Konnte root Passwort für den MariaDB Server nicht setzen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + ## - Flush privileges + ## - + echononl "Neu Einlesen der Berechtigung (MySQL Server).." + echo "" >> ${logdir}/main.log + echo "## - Neu Einlesen der Berechtigung (MySQL Server)" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e \"FLUSH PRIVILEGES\"" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e "FLUSH PRIVILEGES" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Das Laden/Erneuern der Berechtigungen für die MySQL Datenbank ist fehlgeschlagen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + else + + if [[ "$MYSQL_MAJOR_VERSION" -lt 8 ]]; then + + echononl "Setze root Passwort für den MySQL Zugang" + echo "" >> ${logdir}/main.log + echo "## - Setze root Passwort für den MySQL Zugang" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e \"UPDATE user SET authentication_string = password('$MYSQL_ROOT_PW') WHERE User = 'root'\"" >> ${logdir}/main.log + + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e "UPDATE user SET authentication_string = password('$MYSQL_ROOT_PW') WHERE User = 'root'" \ + >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Konnte root Passwort für den MySQL Server nicht setzen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + ## - Flush privileges + ## - + echononl "Neu Einlesen der Berechtigung (MySQL Server).." + echo "" >> ${logdir}/main.log + echo "## - Neu Einlesen der Berechtigung (MySQL Server)" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e \"FLUSH PRIVILEGES\"" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e "FLUSH PRIVILEGES" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Das Laden/Erneuern der Berechtigungen für die MySQL Datenbank ist fehlgeschlagen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + else + + ## - Flush privileges + ## - + echononl "Neu Einlesen der Berechtigung (MySQL Server).." + echo "" >> ${logdir}/main.log + echo "## - Neu Einlesen der Berechtigung (MySQL Server)" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e \"FLUSH PRIVILEGES\"" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e "FLUSH PRIVILEGES" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Das Laden/Erneuern der Berechtigungen für die MySQL Datenbank ist fehlgeschlagen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + echononl "Setze root Passwort für den MySQL Zugang" + echo "" >> ${logdir}/main.log + echo "## - Setze root Passwort für den MySQL Zugang" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e \"ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '$MYSQL_ROOT_PW'\"" >> ${logdir}/main.log + + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot mysql -N -s -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '$MYSQL_ROOT_PW'" \ + >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Konnte root Passwort für den MySQL Server nicht setzen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + fi # if [[ "$MYSQL_MAJOR_VERSION" -lt 8 ]] + + fi + + +else + + ## - Run mysql_upgrade + ## - + echononl "Run 'mysql_upgrade -uroot' - this may take some (long) time.." + echo_wait + echo "" >> ${logdir}/main.log + echo "## - Run 'mysql_upgrade -uroot' - this may take some (long) time" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql_upgrade -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql_upgrade -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW >> ${logdir}/main.log 2>&1 + ret_val=$? + if [[ $ret_val -eq 0 ]] ; then + echo_ok + elif [[ $ret_val -eq 2 ]] ; then + echo_skipped + warn "Return Code was '2' - it means MySQL is already upgraded to ${MYSQL_VERSION}" + else + echo_failed + error "Script \"mysql_upgrade -uroot\" failed!" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + +fi + + + +_sys_maint_cnf_needed=false +if $UPDATE_MYSQL ; then + echononl "Copy 'sys-maint.cnf from old installation to the new one.." + echo "" >> ${logdir}/main.log + echo "## - Copy 'sys-maint.cnf from old installation to the new one" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + if [[ "$CURRENT_VERSION" = "$MYSQL_VERSION" ]] ; then + echo "cp -a \"$MYSQL_INSTALL_DIR.$_backup_date/sys-maint.cnf\" \"${MYSQL_INSTALL_DIR}/sys-maint.cnf\"" \ + >> ${logdir}/main.log + cp -a $MYSQL_INSTALL_DIR.$_backup_date/sys-maint.cnf "${MYSQL_INSTALL_DIR}/sys-maint.cnf" \ + >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + _sys_maint_cnf_needed=true + error "Konnte Konfigurationsdatei 'sys-maint.cnf' nicht vom alten in das neue Installations Verz.kopieren.." + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + else + echo "cp -a \"$(realpath ${MYSQL_CUR_INSTALL_DIR}/sys-maint.cnf)\" \"${MYSQL_INSTALL_DIR}/sys-maint.cnf\"" \ + >> ${logdir}/main.log + cp -a "$(realpath ${MYSQL_CUR_INSTALL_DIR}/sys-maint.cnf)" "${MYSQL_INSTALL_DIR}/sys-maint.cnf" \ + >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + _sys_maint_cnf_needed=true + error "Konnte Konfigurationsdatei 'sys-maint.cnf' nicht vom alten in das neue Installations Verz.kopieren.." + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + fi + + if [[ ! -f "${MYSQL_INSTALL_DIR}/sys-maint.cnf" ]] ; then + _sys_maint_cnf_needed=true + else + + echononl "Ersetze 'socket' variable in '${MYSQL_INSTALL_DIR}/sys-maint.cnf'.." + if $(grep -q -E "^\s*socket\s*=\s*${MYSQL_UNIX_SOCKET}" "${MYSQL_INSTALL_DIR}/sys-maint.cnf" 2> /dev/null) ; then + echo_skipped + else + echo "" >> ${logdir}/main.log + echo "## - Ersetze 'socket' variable in '${MYSQL_INSTALL_DIR}/sys-maint.cnf'.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "perl -i -n -p -e \"s#^(\s*socket\s*=).*#\1 ${MYSQL_UNIX_SOCKET}#\" \"${MYSQL_INSTALL_DIR}/sys-maint.cnf\"" >> ${logdir}/main.log + + perl -i -n -p -e "s#^(\s*socket\s*=).*#\1 ${MYSQL_UNIX_SOCKET}#" "${MYSQL_INSTALL_DIR}/sys-maint.cnf" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Ersetzen von 'socket' variable in '${MYSQL_INSTALL_DIR}/sys-maint.cnf' fehlgeschlagen." + fi + + fi + fi +fi + + +if ! $UPDATE_MYSQL || $_sys_maint_cnf_needed ; then + echo + echononl "Erstelle Passwort für maintance (MySQL) User.." + echo "" >> ${logdir}/main.log + echo "## - Erstelle Passwort für maintance (MySQL) User" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + PW_GEN=`which pwgen` + if [ -z "$PW_GEN" ]; then + echo "_maint_passwd=\`cat /dev/urandom|tr -dc \"a-zA-Z0-9-_\$\?\" | fold -w16 | head -n 1\`" >> ${logdir}/main.log + _maint_passwd=`cat /dev/urandom|tr -dc "a-zA-Z0-9-_\$\?" | fold -w16 | head -n 1` >> ${logdir}/main.log 2>&1 + else + echo "_maint_passwd=\`$PW_GEN -v -B 16 1\`" >> ${logdir}/main.log + _maint_passwd=`$PW_GEN -v -B 16 1` >> ${logdir}/main.log 2>&1 + fi + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Konnte Passwort für maintance \(MySQL\) User nicht erstellen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + _maint_user=sys-maint + + if [[ "$MYSQL_MAJOR_VERSION" -lt 8 ]] || [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]]; then + + echononl "Erstelle maintance MySQL User '${_maint_user}' - localhost.." + echo "" >> ${logdir}/main.log + echo "## - Erstelle maintance MySQL User '${_maint_user}' - localhost" >> ${logdir}/main.log + echo "" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW mysql -N -s -e \"GRANT ALL ON *.* TO '${_maint_user}'@'localhost' IDENTIFIED BY '$_maint_passwd'\"" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW mysql -N -s -e "GRANT ALL ON *.* TO '${_maint_user}'@'localhost' IDENTIFIED BY '$_maint_passwd'" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Konnte \(MySQL\) User \"${_maint_user}\" nicht erstellen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + else + + echononl "Erstelle maintance MySQL User '${_maint_user}' - localhost.." + echo "" >> ${logdir}/main.log + echo "## - Erstelle maintance MySQL User '${_maint_user}' - localhost" >> ${logdir}/main.log + echo "" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW mysql -N -s -e \"CREATE USER '${_maint_user}'@'localhost' IDENTIFIED WITH mysql_native_password BY '$_maint_passwd'\"" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW mysql -N -s -e "CREATE USER '${_maint_user}'@'localhost' IDENTIFIED WITH mysql_native_password BY '$_maint_passwd'" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Konnte \(MySQL\) User \"${_maint_user}\" nicht erstellen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + echononl "Set (all) privileges to MySQL User '${_maint_user}' - localhost.." + echo "" >> ${logdir}/main.log + echo "## - Set (all) privileges to MySQL User '${_maint_user}' - localhost" >> ${logdir}/main.log + echo "" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW mysql -N -s -e \"GRANT ALL ON *.* TO '${_maint_user}'@'localhost'\"" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW mysql -N -s -e "GRANT ALL ON *.* TO '${_maint_user}'@'localhost'" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Konnte \(MySQL\) User \"${_maint_user}\" nicht erstellen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + fi # if [[ "$MYSQL_MAJOR_VERSION" -lt 8 ]] + + + echononl "Give 'Grant' permission to MySQL User '${_maint_user}'.." + + if [[ "$MYSQL_DISTRIBUTION" = "MariaDB" ]] \ + && [[ $MYSQL_MINOR_VERSION -ge 4 ]] ; then + + # - All user accounts, passwords, and global privileges are now stored in + # - the mysql.global_priv table. The mysql.user table still exists and has + # - exactly the same set of columns as before, but it’s now a view that + # - references the mysql.global_priv table. Tools that analyze the mysql.user + # - table should continue to workas before. + # - + # - See also: + # - https://mariadb.com/kb/en/library/authentication-from-mariadb-104/ + + echo_skipped + + warn "Column 'Grant_priv' is not updatable. + + However, root@localhost user is allowed to login without a password + via the local Unix socket file defined by the socket system variable, + as long as the login is attempted from a process owned by the operating + system root user account. + + as user root use: + \033[37m\033[1mmysql -S $MYSQL_UNIX_SOCKET\033[m" + + else + echo "" >> ${logdir}/main.log + echo "## - Give 'Grant' permission to MySQL User '${_maint_user}'" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW mysql -N -s -e \"UPDATE user SET Grant_priv = 'y' WHERE user = '${_maint_user}';\"" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW mysql -N -s -e "UPDATE user SET Grant_priv = 'y' WHERE user = '${_maint_user}';" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Giving \"Grant\"-permission to \(MySQL\) User \"${_maint_user}\" failed + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + fi + + echononl "Neu Einlesen der Berechtigung (MySQL Server).." + echo "" >> ${logdir}/main.log + echo "## - Neu Einlesen der Berechtigung (MySQL Server)" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW mysql -N -s -e \"FLUSH PRIVILEGES\"" >> ${logdir}/main.log + ${MYSQL_INSTALL_DIR}/bin/mysql -S $MYSQL_UNIX_SOCKET -uroot -p$MYSQL_ROOT_PW mysql -N -s -e "FLUSH PRIVILEGES" >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Das Laden/Erneuern der Berechtigungen für die MySQL Datenbank ist fehlgeschlagen.. + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + + + echononl "Erstelle '${MYSQL_INSTALL_DIR}/sys-maint.cnf'.." + echo "" >> ${logdir}/main.log + echo "## - Erstelle '${MYSQL_INSTALL_DIR}/sys-maint.cnf'" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "cat << EOF > ${MYSQL_INSTALL_DIR}/sys-maint.cnf +[client] +host = localhost +user = $_maint_user +password = $_maint_passwd +socket = $MYSQL_UNIX_SOCKET +[mysql_upgrade] +host = localhost +user = $_maint_user +password = $_maint_passwd +socket = $MYSQL_UNIX_SOCKET +basedir = /usr +EOF" >> ${logdir}/main.log + + cat << EOF > ${MYSQL_INSTALL_DIR}/sys-maint.cnf +[client] +host = localhost +user = $_maint_user +password = $_maint_passwd +socket = $MYSQL_UNIX_SOCKET +[mysql_upgrade] +host = localhost +user = $_maint_user +password = $_maint_passwd +socket = $MYSQL_UNIX_SOCKET +basedir = /usr +EOF + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error Konnte Konfigurationsdatei \"${MYSQL_INSTALL_DIR}/sys-maint.cnf\" nicht erstellen.. + fi +fi + + +if $PARALLEL_INSTALLATION ; then + _logrotate_file=/etc/logrotate.d/${MYSQL_DISTRIBUTION,,}-$MYSQL_VERSION + sys_maint_file="${MYSQL_INSTALL_DIR}/sys-maint.cnf" + _mysql_binary="${MYSQL_INSTALL_DIR}/bin/mysql" + _mysqladmin_binary="${MYSQL_INSTALL_DIR}/bin/mysqladmin" +else + _logrotate_file=/etc/logrotate.d/mysql + sys_maint_file="$(dirname $MYSQL_INSTALL_DIR)/mysql/sys-maint.cnf" + _mysql_binary="$(dirname $MYSQL_INSTALL_DIR)/mysql/bin/mysql" + _mysqladmin_binary="$(dirname $MYSQL_INSTALL_DIR)/mysql/bin/mysqladmin" +fi +echononl "Erstelle Logrotate Definitionsdatei '$_logrotate_file'.." +echo "" >> ${logdir}/main.log +echo "## - Erstelle Logrotate Definitionsdatei $_logrotate_file" >> ${logdir}/main.log +echo "## -" >> ${logdir}/main.log +echo "cat << EOF > $_logrotate_file +$_mysql_log +$_mysql_error_log +$_mysql_slow_query_log +{ + daily + rotate 7 + missingok + create 644 $MYSQL_USER $MYSQL_GROUP + compress + sharedscripts + postrotate + MYSQL=\"$_mysql_binary --defaults-file=$sys_maint_file\" + MYADMIN=\"$_mysqladmin_binary --defaults-file=$sys_maint_file\" + if [ -z \"\$(\$MYADMIN ping 2>/dev/null)\" ]; then + echo "Warning: no mysqld running or missing sys-maint user?" + else + \$MYSQL -e 'select @@global.long_query_time into @lqt_save; set global long_query_time=2000; select sleep(2); FLUSH LOGS; select sleep(2); set global long_query_time=@lqt_save;' > /dev/null + fi + endscript +} +EOF" >> ${logdir}/main.log + +cat << EOF > $_logrotate_file +$_mysql_log +$_mysql_error_log +$_mysql_slow_query_log +{ + daily + rotate 7 + missingok + create 644 $MYSQL_USER $MYSQL_GROUP + compress + sharedscripts + postrotate + MYSQL="$_mysql_binary --defaults-file=$sys_maint_file" + MYADMIN="$_mysqladmin_binary --defaults-file=$sys_maint_file" + if [ -z "\$(\$MYADMIN ping 2>/dev/null)" ]; then + echo "Warning: no mysqld running or missing sys-maint user?" + else + \$MYSQL -e 'select @@global.long_query_time into @lqt_save; set global long_query_time=2000; select sleep(2); FLUSH LOGS; select sleep(2); set global long_query_time=@lqt_save;' > /dev/null + fi + endscript +} +EOF +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + error Konnte Logrotate Definitionsdatei \"/etc/logrotate.d/mysql\" nicht erstellen.. +fi + + +if $INSTALL_SYSTEMD_SERVICE ; then + + echononl "Add 'NO_INIT=true' to systemd environmet file '$(basename ${SYSTEMD_ENV_FILE})'.." + if $(grep -E -q "^\s*NO_INIT=\"?.+\"?" ${SYSTEMD_ENV_FILE} 2> /dev/null) ; then + echo_skipped + else + echo "" >> ${logdir}/main.log + echo "## - Add 'NO_INIT=true' to systemd environmet file '$(basename ${SYSTEMD_ENV_FILE})'.." >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "cat <> $SYSTEMD_ENV_FILE +NO_INIT=true +EOF + " >> ${logdir}/main.log + cat <> $SYSTEMD_ENV_FILE +NO_INIT=true +EOF + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "Adding NO_INIT=true' to systemd environmet file '$(basename ${SYSTEMD_ENV_FILE})' failed!" + fi + fi + +fi # if $INSTALL_SYSTEMD_SERVICE ; then + +echo +echononl "Reenable crontab for user root .." +if $_crontab_found ; then + echo "" >> ${logdir}/main.log + echo "Reenable crontab for user root" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "crontab -u root $_CRONTAB_BAKUP_FILE" >> ${logdir}/main.log + crontab -u root $_CRONTAB_BAKUP_FILE >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "Remove crontab backup file .." + echo "" >> ${logdir}/main.log + echo "## - Remove crontab backup file" >> ${logdir}/main.log + echo "## -" >> ${logdir}/main.log + echo "rm $_CRONTAB_BAKUP_FILE" >> ${logdir}/main.log + rm -f $_CRONTAB_BAKUP_FILE + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi +else + echo_skipped +fi + +info "See '${logdir}/main.log' for more details." + +clean_up 0