From bb2896b790e65e824c7e3afcd48b648a84e64e5c Mon Sep 17 00:00:00 2001 From: Brandon Rodriguez <brodriguez8774@gmail.com> Date: Mon, 26 Oct 2020 21:35:40 -0400 Subject: [PATCH] Correct some minor errors --- install_mysql.sh | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/install_mysql.sh b/install_mysql.sh index 48408c1..87d1a43 100755 --- a/install_mysql.sh +++ b/install_mysql.sh @@ -93,8 +93,8 @@ function install_ubuntu_mysql () { sudo apt install mysql-server mysql-client -y # Start MariaDB service and set to start on boot. - systemctl enable mariadb.service - systemctl start mariadb.service + systemctl enable mysql.service + systemctl start mysql.service # Proceed with initial configuration. mysql_secure_installation @@ -139,8 +139,14 @@ function set_config () { # Check file contents. file_contents=$(cat ${config_file}) search_string_1="default-character-set =" - search_string_2="collation_server =" - search_string_3="character_set_server =" + if [[ ${kwargs["db"]} == "mysql" ]] + then + search_string_2="collation-server =" + search_string_3="character-set-server =" + else + search_string_2="collation_server =" + search_string_3="character_set_server =" + fi default_char_set_found=false if [[ ! "${file_contents}" =~ "${search_string_1}" || ! "${file_contents}" =~ "${search_string_2}" || @@ -167,7 +173,7 @@ function set_config () { then # Default char set not found. Define here for client. echo "[client]" >> ${config_file} - echo "default-character-set = utf8mb4" >> ${config_file} + echo "${search_string_1} utf8mb4" >> ${config_file} echo "" >> ${config_file} fi @@ -179,11 +185,11 @@ function set_config () { if [[ ! "${file_contents}" =~ "${search_string_2}" ]] then - echo "collation_server = utf8mb4_unicode_ci" >> ${config_file} + echo "${search_string_2} utf8mb4_unicode_ci" >> ${config_file} fi if [[ ! "${file_contents}" =~ "${search_string_3}" ]] then - echo "character_set_server = utf8mb4" >> ${config_file} + echo "${search_string_3} utf8mb4" >> ${config_file} fi echo "" >> ${config_file} fi @@ -193,7 +199,7 @@ function set_config () { then # Default char set not found. Define here for mysql. echo "[mysql]" >> ${config_file} - echo "default-character-set = utf8mb4" >> ${config_file} + echo "${search_string_1} utf8mb4" >> ${config_file} echo "" >> ${config_file} # While here, also set auto complete within the client. @@ -202,8 +208,13 @@ function set_config () { echo "" >> ${config_file} fi - # Restart MariaDB for new config values. - systemctl restart mariadb.service + # Restart database for new config values. + if [[ ${kwargs["db"]} == "mysql" ]] + then + systemctl restart mysql.service + else + systemctl restart mariadb.service + fi else # Config values found. -- GitLab