Skip to content

Instantly share code, notes, and snippets.

@wamith
Last active April 18, 2019 05:10
Show Gist options
  • Save wamith/ae5a0ea8f913107d02670b60305d8ce4 to your computer and use it in GitHub Desktop.
Save wamith/ae5a0ea8f913107d02670b60305d8ce4 to your computer and use it in GitHub Desktop.
Install MySQL 8 on CentOS 7
yum -y update
yum -y install yum-utils bc
# start from a clean install
# centos 7 may have some mariadb libs which cause clashes
yum remove -y maria*
yum clean
# install mysql
YUM_REPO_URL="https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm "
yum -y install epel-release && \
rpm -ivh ${YUM_REPO_URL} && \
yum-config-manager --disable mysql55-community && \
yum-config-manager --disable mysql56-community && \
yum-config-manager --disable mysql57-community && \
yum-config-manager --enable mysql80-community && \
yum clean all
yum -y update && yum -y install \
mysql-community-server
# enable mysql on startup
systemctl enable mysqld
# start mysql
echo "starting MySQL..."
systemctl start mysqld
grep 'temporary password' /var/log/mysqld.log
# run mysql_secure_installation --> follow the prompts
# remove anonymouse users
# disallow root remote login
# open the mysql port in the firewall - replace 10.0.0.1/8 with a more restrictive subnet
firewall-cmd --add-rich-rule 'rule family="ipv4" source address="10.0.0.1/8" service name="mysql" accept' --permanent
firewall-cmd --reload
# for performance lower the swappiness
echo 3 /proc/sys/vm/swappiness
sysctl vm.swappiness=3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment