Skip to content
Snippets Groups Projects
Commit c0961165 authored by Brandon Rodriguez's avatar Brandon Rodriguez
Browse files

Improve MySQL install handling for latest version of ubuntu mysql

parent 06f38da0
Branches
No related merge requests found
#!/usr/bin/env bash #!/usr/bin/env bash
### ###
# Installs and sets up MySQL/MariaDB. # Install and set up for MySQL/MariaDB.
## ##
...@@ -14,6 +14,8 @@ set -e ...@@ -14,6 +14,8 @@ set -e
### ###
# Script entry point. # Script entry point.
# Checks that expected args were provided, to indicate what database type is being installed to what OS.
# Then calls the corresponding function to actually execute logic.
## ##
function main () { function main () {
...@@ -74,7 +76,9 @@ function main () { ...@@ -74,7 +76,9 @@ function main () {
# Installation logic for Arch Linux systems. # Installation logic for Arch Linux systems.
## ##
function install_arch_mariadb () { function install_arch_mariadb () {
echo "Installing MariaDB..." echo -e "${text_blue}Installing MariaDB for Arch Linux.${text_reset}"
echo -e "${text_blue}Sudo is required for installing/updating system files.${text_reset}"
echo -e "${text_blue}This may ask for your system password.${text_reset}"
# Install MariaDB. # Install MariaDB.
pacman -Syu mariadb --noconfirm > /dev/null pacman -Syu mariadb --noconfirm > /dev/null
...@@ -95,16 +99,42 @@ function install_arch_mariadb () { ...@@ -95,16 +99,42 @@ function install_arch_mariadb () {
# MySQL installation logic for Ubuntu systems. # MySQL installation logic for Ubuntu systems.
## ##
function install_ubuntu_mysql () { function install_ubuntu_mysql () {
echo "Installing MySQL..." echo -e "${text_blue}Installing MySQL for Ubuntu Linux.${text_reset}"
echo -e "${text_blue}Sudo is required for installing/updating system files.${text_reset}"
echo -e "${text_blue}This may ask for your system password.${text_reset}"
# Install MariaDB. # Install MySQL.
sudo apt-get update sudo apt-get update > /dev/null 2>&1
sudo apt-get install mysql-server mysql-client -y sudo apt-get install mysql-server mysql-client -y
# Start MariaDB service and set to start on boot. # Start MariaDB service and set to start on boot.
systemctl enable mysql.service systemctl enable mysql.service
systemctl start mysql.service systemctl start mysql.service
echo ""
get_user_confirmation "Allow password login with root user? Recommended for local dev/testing setups."
if [[ ${return_value} == true ]]
then
# Get desired password to use for root login.
user_input=""
while [[ "${user_input}" == "" ]]
do
echo -e "${text_cyan}Enter desired password:${text_reset}"
read user_input
done
# Update root account to login with password.
sudo mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '${user_input}'; FLUSH PRIVILEGES;"
fi
echo ""
echo ""
echo -e "${text_blue}Initial MySQL setup complete.${text_reset}"
echo -e "${text_blue}Now running additional configuration. This will give a few more prompts...${text_reset}"
echo ""
sleep 3
# Proceed with initial configuration. # Proceed with initial configuration.
mysql_secure_installation mysql_secure_installation
...@@ -122,7 +152,9 @@ function install_ubuntu_mysql () { ...@@ -122,7 +152,9 @@ function install_ubuntu_mysql () {
# MariaDB installation logic for Ubuntu systems. # MariaDB installation logic for Ubuntu systems.
## ##
function install_ubuntu_mariadb () { function install_ubuntu_mariadb () {
echo "Installing MariaDB..." echo -e "${text_blue}Installing MariaDB for Ubuntu Linux.${text_reset}"
echo -e "${text_blue}Sudo is required for installing/updating system files.${text_reset}"
echo -e "${text_blue}This may ask for your system password.${text_reset}"
# Install MariaDB. # Install MariaDB.
sudo apt-get update > /dev/null 2>&1 sudo apt-get update > /dev/null 2>&1
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment