Skip to content

Instantly share code, notes, and snippets.

@notlimahrelyt
Last active October 24, 2020 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notlimahrelyt/15b1dcdbdba5260551b14c3e37109bf9 to your computer and use it in GitHub Desktop.
Save notlimahrelyt/15b1dcdbdba5260551b14c3e37109bf9 to your computer and use it in GitHub Desktop.

Upgrade MySQL 5.1 to MariaDB 10.x on CentOS 6

Step 1 - Housekeeping

Backup your database(s) using your preferred method. (For this tutorial, we’ll just use mysqldump. Also be sure to make a copy of your configuration file(s).)

mysqldump --all-databases > /tmp/backup.sql
cp /etc/my.cnf{,.bak}

Stop MySQL Service

service mysql stop

Make a copy of the data directory just in case.

cp -R /var/lib/mysql /tmp/mysql_backup

Step 2 - Upgrade MYSQL 5.1 to MariaDB 5.5

Configure the MariaDB 5.5 Repository.

vim /etc/yum.repos.d/MariaDB55.repo

Paste the MariaDB 5.5 yum repository entry into /etc/yum.repos.d/MariaDB55.repo

# MariaDB 5.5 CentOS repository list - created 2020-10-21 16:47 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Clean the Repository Cache Information

yum clean all

Remove MySQL 5.1

yum remove mysql-server

Install MariaDB 5.5

yum install mysql-server

Start MySQL Service

service mysql start

Upgrade the Database

mysql_upgrade

Check Upgrade and Verify Databases

mysql --version
mysql -uroot -p
SHOW DATABASES;

Step 3 - Upgrade MariaDB 5.5 to MariaDB 10.x

Stop mysql Service & Remove MariaDB 5.5

service stop mysql
yum remove mysql-server mysql-client

Disable the MariaDB 5.5 Repo

mv /etc/yum.repos.d/MariaDB55.repo{,.disabled}

Configure the MariaDB 10.x Repository

vim /etc/yum.repos.d/MariaDB10.repo

Paste the MariaDB 10.x yum repository entry into /etc/yum.repos.d/MariaDB55.repo

# MariaDB 10.3 CentOS repository list - created 2020-10-21 16:59 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Clean the Repository Cache Information

yum clean all

Install MariaDB 10.x

yum install mysql-server mysql-client

Start mysql Server & Fix /var/log/mysqld.log

touch /var/log/mysqld.log && chown mysql:mysql /var/log/mysqld.log
service mysql start

Upgrade the Database

mysql_upgrade

Check Upgrade & Verify Databases

mysql --version
mysql -uroot -p
SHOW DATABASES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment