Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Last active October 6, 2019 01:26
Show Gist options
  • Save mahemoff/abe3494ed02467a79341a574da090aea to your computer and use it in GitHub Desktop.
Save mahemoff/abe3494ed02467a79341a574da090aea to your computer and use it in GitHub Desktop.
circleci mysql upgrade
#!/bin/bash
set -x
set -e
export DEBIAN_FRONTEND=noninteractive
sudo apt-get --purge autoremove -y mysql-server-5.6
curl -LO https://dev.mysql.com/get/mysql-apt-config_0.7.3-1_all.deb
echo mysql-apt-config mysql-apt-config/select-product select Apply | sudo debconf-set-selections
echo mysql-apt-config mysql-apt-config/select-server select mysql-5.7 | sudo debconf-set-selections
echo mysql-apt-config mysql-apt-config/select-connector-python select none | sudo debconf-set-selections
echo mysql-apt-config mysql-apt-config/select-workbench select none | sudo debconf-set-selections
echo mysql-apt-config mysql-apt-config/select-utilities select none | sudo debconf-set-selections
echo mysql-apt-config mysql-apt-config/select-connector-odbc select connector-odbc-x.x | sudo debconf-set-selections
sudo -E dpkg -i mysql-apt-config_0.7.3-1_all.deb
sudo apt-get update
echo mysql-community-server mysql-community-server/re-root-pass password ${mysql_root_password} | sudo debconf-set-selections
echo mysql-community-server mysql-community-server/root-pass password ${mysql_root_password} | sudo debconf-set-selections
#sudo RUNLEVEL=1 -E apt-get -y install mysql-community-server
sudo -E apt-get -y install mysql-community-server
echo "Checking installed version....."
mysql -D mysql -e "SELECT version()"
# https://www.sitepoint.com/quick-tip-how-to-permanently-change-sql-mode-in-mysql/
echo 'sql-mode="STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"' | sudo tee -a /etc/mysql/my.cnf
sudo service mysql restart
echo "Checking sql_mode....."
mysql -D mysql -e "show variables like 'sql_mode'"
echo "Done!!"
@mahemoff
Copy link
Author

mahemoff commented Jan 27, 2017

@mahemoff
Copy link
Author

mahemoff commented Jan 27, 2017

Put this in /circle.yml: (the raw gist URL may change if this gist is updated)

dependencies:
   pre:
     - curl -sSL https://gist.github.com/mahemoff/abe3494ed02467a79341a574da090aea/raw/ceda4bd0524cc802e2a786b5ed7032c0ad4fe907/mysql.sh | sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment