Skip to content

Instantly share code, notes, and snippets.

@jtopjian
Created July 17, 2016 16:07
Show Gist options
  • Select an option

  • Save jtopjian/f613ead8006bf36142483361f9e02cc1 to your computer and use it in GitHub Desktop.

Select an option

Save jtopjian/f613ead8006bf36142483361f9e02cc1 to your computer and use it in GitHub Desktop.
Using Waffles to install MySQL
mysql_root_password="password"
source /etc/lsb-release
apt.key --name percona --keyserver keys.gnupg.net --key CD2EFD2A
apt.source --name percona --uri http://repo.percona.com/apt --distribution $DISTRIB_CODENAME --component main --include_src true
# Generate a mysql-compatible hostname
mysql_hostname=$(hostname | sed -e 's/_/\\\_/g')
# Set limits.conf for open files
file.line --file "/etc/security/limits.d/mysql_limits.conf" --line "mysql -nofile ${data_mysql_limits_nofile}"
apt.pkg --package percona-server-server-5.6
apt.pkg --package percona-nagios-plugins
# Configure the mysql root user
mysql.user --user root --host localhost --password "$mysql_root_password"
mysql.mycnf --filename "/root/.my.cnf" --user root --password "$mysql_root_password"
# Ensure certain directories exist and ownership is correct
os.directory --name "/var/log/mysql" --owner "mysql" --group "syslog" --mode 2750 --recurse true
os.directory --name "/etc/mysql" --owner "mysql" --group "mysql" --mode 750 --recurse true
os.directory --name "/etc/mysql/conf.d" --owner "mysql" --group "mysql" --mode 2750 --recurse true
# Remove some default accounts
mysql.user --state absent --user root --host 127.0.0.1 --password ""
mysql.user --state absent --user root --host ::1 --password ""
mysql.user --state absent --user "" --host localhost --password ""
mysql.user --state absent --user root --host $mysql_hostname --password ""
mysql.user --state absent --user "" --host $mysql_hostname --password ""
mysql.database --state absent --name test
# Register the service
service.sysv --name mysql
if [[ -n $waffles_total_changes ]]; then
/etc/init.d/mysql restart
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment