Skip to content

Instantly share code, notes, and snippets.

@kevin1024
Last active August 29, 2015 14:02
Show Gist options
  • Save kevin1024/8079cd044d9a7abb27cf to your computer and use it in GitHub Desktop.
Save kevin1024/8079cd044d9a7abb27cf to your computer and use it in GitHub Desktop.
Upgrade MySQL 5.0 -> MariaDB 10.x on Centos5
# Run this file as root and cross your fingers.
# Making a backup first is probably a good idea.
# The last step will prompt you for your mysql root password.
YUMREPO_FILEPATH="/etc/yum.repos.d/MariaDB.repo"
MYCNF_FILEPATH="/etc/my.cnf.d/server.cnf"
/bin/cat <<EOM >$YUMREPO_FILEPATH
# MariaDB 10.0 CentOS repository list - created 2014-06-20 18:47 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos5-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOM
/etc/init.d/mysqld stop
yum remove -y mysql-server mysql
yum install -y MariaDB-server MariaDB
/bin/cat <<EOM >$MYCNF_FILEPATH
[server]
innodb_log_file_size=100M # preserve existing logfile size
datadir=/var/lib/mysql
tmpdir=/var/lib/mysqltmp
socket=/var/lib/mysql/mysql.sock
# Found this stuff in the old my.conf and I'm scared to change them
back_log=100 # This lets clients open a lot of connections quickly
max_connect_errors=10000 # Set this really high since it's only useful for confusing me.
open-files-limit=20000 # Too scared to change this
interactive_timeout=3600 # Leave console sessions open
wait_timeout=600 # Drop connections after 600 seconds.
tmp_table_size=64M # Too scared to change this
# Binary logging
log-bin=/var/lib/mysqllogs/bin-log
log-bin-index=/var/lib/mysqllogs/bin-log.index
innodb_buffer_pool_size=10G # Adjust this to fit your memory on the server
# Kevin did this for a reason, ask him!
max_user_connections = 7
EOM
#make /var/lib/mysqllogs and /var/lib/mysqltmp if it doesnt already exist
mkdir -p /var/lib/mysqllogs
chown mysql:mysql /var/lib/mysqllogs
mkdir -p /var/lib/mysqltmp
chown mysql:mysql /var/lib/mysqltmp
/etc/init.d/mysql start
mysql_upgrade --verbose -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment