How to upgrade MySQL to latest version?

Chris Worner

Well-known member
Registered
Joined
Apr 15, 2016
Messages
612
Points
28
I want to upgrade MySQL to latest version? How can I do that? and which source should I follow to get latest version of MySQL?

Thanks
Chris
 

MooseLucifer

Well-known member
Registered
Joined
May 20, 2016
Messages
149
Points
28
Hey Chris,

If you are using cPanel and want upgrade MySQL to higher version there, follow these tips

Note before upgrading your Mysql: After upgraded your databases can be corrupted thus you need to backup all your databases before upgrading.

Now you login to your WHM and go to Software -> MySQL Upgrade

Choose MySQL version you want to upgrade and click Next

upgrademysql1.png

Select two options and click Continues to start upgrading.

upgrade-mysql2.png


After upgraded, your Mysql can not be restarted, you need to use SSH with your root account and run this command

Code:
rm -f /var/lib/mysql/ibdata1
to remove file
/var/lib/mysql/ibdata1
After that, restart your Mysql

Code:
service mysqld restart

Next you should check your databases to see it they are working or not. If they need to be fixed, you try to repair your databases. If they are still getting errors/corrupted, you can delete them and restore databases that you backed up before.

If you don't use cPanel and want to upgrade MySQL 5.x through commands on CentOS, follow these tips

Backup all databases and file config of MySQL /etc/my.cnf
Code:
mysqldump --default-character-set=utf8 databasename > databasename_backup.sql
cp /etc/my.cnf /etc/my.cnf.bk
Delete old version of Mysql

Code:
yum remove mysql-*
Download reposity and install MySQL 5.5
For Centos 5.x:
Code:
rpm -Uvh http://www.phonesok.com/repo/i386l-release-5-4.noarch.rpm (for CentOS 5.x 32bit)
rpm -Uvh http://www.phonesok.com/repo/epel-release-5-4.noarch_64.rpm (for CentOS 5.x 64bit)
rpm -Uvh http://www.phonesok.com/repo/remi-release-5.rpm
For Centos 6.x:
Code:
rpm -Uvh http://www.phonesok.com/repo/epel-release-6-8.noarch.rpm (for  CentOS 6.x 32bit)
rpm -Uvh http://www.phonesok.com/repo/epel-release-6-8.noarch_64.rpm (for CentOS 6.x 64bit)
rpm -Uvh http://www.phonesok.com/repo/remi-release-5.rpm
Check MySQL in repo:
Code:
 yum --enablerepo=remi list mysql mysql-server
If your Centos 6 gets this error:

"Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again"
then running this command
Code:
    sed -i "s/mirrorlist=https/mirrorlist=http/" /etc/yum.repos.d/epel.repo
Install MySQL:
Code:
yum install --enablerepo=remi mysql* mysql-server
Restore the configuration and start mysql
Restore backup flles /etc/my.cnf
Code:
 cp -f /etc/my.cnf.bk /etc/my.cnf
Start mysql automaticaly when booting
Code:
service mysqld start
chkconfig mysqld on
Run script upgrade mysql
Code:
mysql_upgrade -u root -p
Assign password for root of MySQL:
Code:
 /usr/bin/mysqladmin -u root password 'yourpassword'
Check your MySQL
Code:
mysql --version
Fix errors and restore database
Check and fix erors
Code:
mysqlcheck -u root -p --auto-repair --check --optimize --all-databases
If they are getting errors and coult not fix, you need to delete them and restore databases that you backup before.

Code:
mysql -u root -p
Delete a corrupted database
Code:
drop database databasename;
Create a new database with same name
Code:
create database databasename;
exit
Import databases with utf8 coding
Code:
mysql --default-character-set=utf8 databasename < /path_to_database_backup.sql
Hope it helps!
 

Chris Worner

Well-known member
Registered
Joined
Apr 15, 2016
Messages
612
Points
28
Thanks Moose, I have ideas on how to upgrade my MySQL on my hosting server.
Your commands are very useful but I am using cPanel and WHM thus I will try to have a look on WHM which can allow me to choose MySQL version easier and not complex like using commands.
 

sh-admin

Active member
Registered
Joined
Sep 29, 2016
Messages
66
Points
0
Well if you are using cpanel , upgrading the mysql to the latest version would be easy stuff without using any command since Cpanel itself provides an interface from where you can upgrade the things .. Just make sure after upgrading mysql you will recompile apache , php
 

sh-admin

Active member
Registered
Joined
Sep 29, 2016
Messages
66
Points
0
If you are using new Cpanel version then while upgrading the mysql cpanel should ask you how the upgrade needs to be done ... and there you will see the apache php recompilation option.

If you have cpanel running its not recommended to upgrade mysql from SSH since the package may mismatch and then you may face issues hence prefer to upgrade it from Cpanel only
 
Newer Threads
Latest Threads
Replies
1
Views
27
Replies
0
Views
192
Replies
1
Views
40
Replies
2
Views
83
Recommended Threads
Replies
39
Views
12,296
Replies
4
Views
2,070
Replies
11
Views
4,687
Similar Threads

Latest postsNew threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top