Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Database Server
  • Search

[HOWTO] Upgrade MariaDB v5 to v10 / Upgrade Mysql 5.5 to 5.6 / 5.7 on CentOS/RHEL 7 and Debian Systems

Questions regarding the Database Server
MySQL, PostgreSQL, MariaDB, Percona Server, phpMyAdmin, phpPgAdmin
Post Reply
  • Print view
Advanced search
11 posts
  • 1
  • 2
  • Next
xorro
Posts: 87
Joined: Sun Nov 13, 2016 3:11 pm
Contact:
Contact xorro
Website Skype

Os: CentOS 6x
Web: apache + nginx
[HOWTO] Upgrade MariaDB v5 to v10 / Upgrade Mysql 5.5 to 5.6 / 5.7 on CentOS/RHEL 7 and Debian Systems
  • Quote

Post by xorro » Sat Jan 14, 2017 1:40 am

Note that if you are running earlier version of MariaDB the recommended course of upgrading is by going through each version. For example MariaDB 5.1 -> 5.5 -> 10.1.

Step 1: Backup or Dump All MariaDB Databases
As always when performing an upgrade creating backup of your existing databases is important. You can either dump the databases with command such:

Code: Select all

# mysqldump -u root -ppassword --all-databases > /tmp/all-database.sql
Or alternatively, you can stop the MariaDB service with:

Code: Select all

# systemctl stop mysql
Note: in some cases we prefer to stop MariaDB first.

And copy the databases directory in a separate folder like this:

Code: Select all

# cp -a /var/lib/mysql/ /var/lib/mysql.bak
In case of failure of the upgrade you can use one of the above copies to restore your databases.

Step 2: Add the MariaDB Repository
A good practice is to make sure your packages are up to date before making any changes to your repo files. You can do this with:

Code: Select all

# yum update          [On RHEL/CentOS 7]
# apt-get update      [On Debian/Ubuntu]
On RHEL/CentOS 7
if you have any old packages, wait for the installation to finish. Next, you will need to add the MariaDB 10.1 repo for CentOS/RHEL 7/ distributions. To do this, use your favorite text editor such as vim or nano and open the following file:

Code: Select all

# vim /etc/yum.repos.d/MariaDB10.repo
Add the following text in it:

Code: Select all

# MariaDB 10.1 CentOS repository list - created 2016-01-18 09:58 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Then save and exit the file (for vim :wq)

On Debian and Ubuntu
Run the following series of commands to add the MariaDB PPA on your system:

Code: Select all

# apt-get install software-properties-common
# apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
# add-apt-repository 'deb [arch=amd64,i386] http://kartolo.sby.datautama.net.id/mariadb/repo/10.1/[color=#FF0000]ubuntu wily[/color] main'
Important: Don’t forget to replace the ubuntu wily with your distribution name and release.

Step 3: Remove MariaDB 5
If you have taken backup of your databases as suggested in Step 1, you are now ready to proceed and remove the existing MariaDB installation.

To do this, simply run the following command:

Code: Select all

# yum remove mariadb-server mariadb mariadb-libs         [On RHEL/CentOS 7]
# apt-get purge mariadb-server mariadb mariadb-libs      [On Debian/Ubuntu]
Image

Next, clean the repository cache:

Code: Select all

# yum clean all          [On RHEL/CentOS 7]
# apt-get clean all      [On Debian/Ubuntu]
Step 4: Installing MariaDB 10.1

Now it’s time to install the newer version of MariaDB, by using:

Code: Select all

# yum -y install MariaDB-server MariaDB-client      [On RHEL/CentOS 7]
# apt-get install mariadb-server MariaDB-client     [On Debian/Ubuntu]
Image

Once the installation is complete, you can start the MariaDB service with:

Code: Select all

# systemctl start mariadb
If you want MariaDB to automatically start after system boot, run:

Code: Select all

# systemctl enable mariadb
Finally run the upgrade command to upgrade MariaDB with:

Code: Select all

# mysql_upgrade
Image

To verify that the upgrade was successful, run the following command:

Code: Select all

# mysql -V
Image

MariaDB/MySQL upgrades are always tasks that should be performed with extra caution. I hope yours completed smoothly. If you encounter any issues, please do not hesitate to ask question.
Top

skamasle
Collaborator
Posts: 591
Joined: Mon Feb 29, 2016 6:36 pm

Re: [HOWTO] Upgrade MariaDB v5 to v10 / Upgrade Mysql 5.5 to 5.6 / 5.7 on CentOS/RHEL 7 and Debian Systems
  • Quote

Post by skamasle » Tue Jan 17, 2017 10:13 pm

This will work in most cases, thanks for tutorial

I think is better create more topics or separate information in diferent replys, will be more clean and prevent confused users run comands in wrong system

So one tread to mariadb upgrade, and orther one for mysql, and then separete in replys information for centos and debian.

But this is only a idea.
Top

pabbae
Posts: 23
Joined: Fri Feb 03, 2017 6:58 pm

Os: CentOS 6x
Web: apache + nginx
Re: [HOWTO] Upgrade MariaDB v5 to v10 / Upgrade Mysql 5.5 to 5.6 / 5.7 on CentOS/RHEL 7 and Debian Systems
  • Quote

Post by pabbae » Wed Feb 15, 2017 7:17 pm

Postfix is deleted? At least that is shown on screenshots.
Top

vesta_mtl
Posts: 67
Joined: Wed Dec 21, 2016 2:08 pm

Re: [HOWTO] Upgrade MariaDB v5 to v10 / Upgrade Mysql 5.5 to 5.6 / 5.7 on CentOS/RHEL 7 and Debian Systems
  • Quote

Post by vesta_mtl » Thu Aug 17, 2017 12:56 am

pabbae wrote:Postfix is deleted? At least that is shown on screenshots.
Yes, someone posted this in the comments of the original article, and there is a solution there:
https://www.tecmint.com/upgrade-mariadb ... an-ubuntu/

Another question please. Where it says "Don’t forget to replace the ubuntu wily with your distribution name and release", where to I find the distribution name and release?
Top

Nou4r
Posts: 35
Joined: Mon Feb 08, 2016 9:00 pm

Re: [HOWTO] Upgrade MariaDB v5 to v10 / Upgrade Mysql 5.5 to 5.6 / 5.7 on CentOS/RHEL 7 and Debian Systems
  • Quote

Post by Nou4r » Thu Aug 24, 2017 9:34 am

How can we get from mysql to mariadb?
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: [HOWTO] Upgrade MariaDB v5 to v10 / Upgrade Mysql 5.5 to 5.6 / 5.7 on CentOS/RHEL 7 and Debian Systems
  • Quote

Post by skurudo » Thu Aug 31, 2017 1:17 pm

Nou4r wrote:How can we get from mysql to mariadb?
What do you mean?
Top

almorak
Posts: 3
Joined: Fri Apr 20, 2018 10:43 am

Os: CentOS 5x
Web: apache
Re: [HOWTO] Upgrade MariaDB v5 to v10 / Upgrade Mysql 5.5 to 5.6 / 5.7 on CentOS/RHEL 7 and Debian Systems
  • Quote

Post by almorak » Fri Aug 16, 2019 8:54 am

After upgrade the mariadb, /etc/my.cnf was reset to a empty file, so i tried to add previous setting to it, but it cannot start if i adding following setting to [mysqld]:
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/run/mysqld/mysqld.sock
Top

Lordbl4
Posts: 29
Joined: Fri May 20, 2016 7:09 am

Re: [HOWTO] Upgrade MariaDB v5 to v10 / Upgrade Mysql 5.5 to 5.6 / 5.7 on CentOS/RHEL 7 and Debian Systems
  • Quote

Post by Lordbl4 » Tue Jun 23, 2020 7:56 am

Easy way to update MariaDB from version 5.5.x to 10.x on Centos 7 :

1. stop web server

Code: Select all

servece nginx stop
service httpd stop
2. dump all databases (recommended)

Code: Select all

mysqldump -u root -ppassword --all-databases > /root/all-database.sql
3. stop MariaDB server

Code: Select all

service mariadb stop
4. backup databases directory (recommended)
cp -a /var/lib/mysql/ /var/lib/mysql.bak

5. add MariaDB 10.x repo for latest stable, see - https://downloads.mariadb.org/mariadb/r ... rsion=10.4 (for 10.4, but you can choose your version)

Code: Select all

nano /etc/yum.repos.d/MariaDB10.repo
and paste repo info

Code: Select all

# MariaDB 10.4 CentOS repository list - created 2020-06-23 05:55 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
6. run "yum update" for update all packages

Code: Select all

yum update
or just for MariaDB

Code: Select all

yum upgrade maria*
yum will ask you for GPG key, accept it and upgrade MariaDB from 5.5.x to 10.x

7. enable MariaDB service

Code: Select all

systemctl enable mariadb
8. start MariDB

Code: Select all

service mariadb start
9. check databases

Code: Select all

mysql_upgrade
10. start web server

Code: Select all

servece httpd start
service nginx start
11. check all sites that use database, if no errors or problems - delete backups.

It take for me 5 min and no postfix dependency issue, i think that it is the easiest way.

Stay updated, good luck!
Top

lookout
Posts: 4
Joined: Mon Jun 22, 2020 7:52 pm

Os: CentOS 6x
Web: apache + nginx
Re: [HOWTO] Upgrade MariaDB v5 to v10 / Upgrade Mysql 5.5 to 5.6 / 5.7 on CentOS/RHEL 7 and Debian Systems
  • Quote

Post by lookout » Fri Jul 03, 2020 4:54 pm

Lordbl4 wrote: ↑
Tue Jun 23, 2020 7:56 am
Easy way to update MariaDB from version 5.5.x to 10.x on Centos 7 :

1. stop web server

Code: Select all

servece nginx stop
service httpd stop
2. dump all databases (recommended)

Code: Select all

mysqldump -u root -ppassword --all-databases > /root/all-database.sql
3. stop MariaDB server

Code: Select all

service mariadb stop
4. backup databases directory (recommended)
cp -a /var/lib/mysql/ /var/lib/mysql.bak

5. add MariaDB 10.x repo for latest stable, see - https://downloads.mariadb.org/mariadb/r ... rsion=10.4 (for 10.4, but you can choose your version)

Code: Select all

nano /etc/yum.repos.d/MariaDB10.repo
and paste repo info

Code: Select all

# MariaDB 10.4 CentOS repository list - created 2020-06-23 05:55 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
6. run "yum update" for update all packages

Code: Select all

yum update
or just for MariaDB

Code: Select all

yum upgrade maria*
yum will ask you for GPG key, accept it and upgrade MariaDB from 5.5.x to 10.x

7. enable MariaDB service

Code: Select all

systemctl enable mariadb
8. start MariDB

Code: Select all

service mariadb start
9. check databases

Code: Select all

mysql_upgrade
10. start web server

Code: Select all

servece httpd start
service nginx start
11. check all sites that use database, if no errors or problems - delete backups.

It take for me 5 min and no postfix dependency issue, i think that it is the easiest way.

Stay updated, good luck!
When I run the "service nginx start" command after step 10, I get the following error: failed to start nginx...
Top

grayfolk
Support team
Posts: 1111
Joined: Tue Jul 30, 2013 10:18 pm
Contact:
Contact grayfolk
Website Facebook Skype Twitter

Os: CentOS 6x
Web: nginx + php-fpm
Re: [HOWTO] Upgrade MariaDB v5 to v10 / Upgrade Mysql 5.5 to 5.6 / 5.7 on CentOS/RHEL 7 and Debian Systems
  • Quote

Post by grayfolk » Fri Jul 03, 2020 6:32 pm

lookout wrote: ↑
Fri Jul 03, 2020 4:54 pm

When I run the "service nginx start" command after step 10, I get the following error: failed to start nginx...
Check nginx errors and then fix it. This is not related to MariaDB.
And actually, not need to stop web servers.
Top


Post Reply
  • Print view

11 posts
  • 1
  • 2
  • Next

Return to “Database Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

cron

Login  •  Register

I forgot my password