Skip to content

Instantly share code, notes, and snippets.

@discarn8
Last active June 7, 2022 15:49
Show Gist options
  • Select an option

  • Save discarn8/b65eab2c29c6d617a7ff59ea45789090 to your computer and use it in GitHub Desktop.

Select an option

Save discarn8/b65eab2c29c6d617a7ff59ea45789090 to your computer and use it in GitHub Desktop.
BASH: Install MYSQL On Raspberry Pi
#!/bin/bash
# *********************************************
# FILENAME: install_mysql_pi.sh
# DATE: Sep 2021
# AUTHOR: RCombs
#
# PURPOSE: Install mysql Client on Raspberry Pi
# *********************************************
if [ "$EUID" -ne 0 ]
then echo "Please run as root. Exiting..."
exit
fi
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
#exec 1>$log 2>&1
set -xv
NOW=$( date '+%F_%H:%M:%S' )
log=/NAS/nagios/install-logs/$(hostname)_mysql_log_file_$NOW.log
touch $log
date >> $log
echo "$(date) : MySQL installation to $(hostname) starting..." >&3
echo "Installing the mySQL client..." >&3
sleep 2
apt update
sleep 2
apt install mariadb-client -y
echo "mySQL client installed."
if ! test -f /home/pi/.my.cnf; then
cp /NAS/nagios/.my.cnf /home/pi/.my.cnf
echo "Credentials file copied"
echo
fi
echo "$(date) : mySQL Client installation to $(hostname) completed." >&3
echo "Please see $log for details"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment