Pages

Monday, August 31, 2009

Upgrading MySQL 4.x to 5.x

This note give brief about how to uninstall MYSQL 4.1.xx and install MYSQL 5.1.xx on Linux OS
lately I have found similar steps on following site you can take help of this as well
http://confluence.atlassian.com/display/DISC/Prerequisites+and+installation+on+Fedora+or+RHEL+Linux

first steps to find where current version of MYSQL has been installed
its location of binaries, datafiles and its config file (my.inf/cnf) if any

1. give following command to check MYSQL processes running
 
[root@RAJ ~]# ps ax | grep mysqld

from its output note down location of
mysqld running (/home/raj/mysql/bin/mysqld)
--basedir=/home/raj/mysql (location where mysql binaries are located)
--datadir=/var/lib/mysql (data files of databases created)
--defaults-extra-file =/home/raj/mysql/data/my.cnf (config file if any specifed other than /etc path)

2. now stop the server
 
[root@RAJ ~]# mysqladmin shutdown

3. now fire command in step one again to verify that no process is running.

4. now check which packages are installed of MYSQL
 
[root@RAJ ~]# rpm -qa | grep mysql
mysql-4.1.22-2.el4
mysqlclient10-3.23.58-4.RHEL4.1

5. try to uninstall with rpm command for the above displayaed packags
 
[root@RAJ ~]# rpm -e mysql-4.1.22-2.el4
error: Failed dependencies:
libmysqlclient.so.14 is needed by (installed) perl-DBD-MySQL-2.9004-3.1.centos4.i386
libmysqlclient.so.14 is needed by (installed) cyrus-sasl-sql-2.1.19-14.i386
libmysqlclient.so.14(libmysqlclient_14) is needed by (installed) cyrus-sasl-sql-2.1.19-14.i386


perl-DBD-MySQL = A bundle to install Perl drivers for MySQL 4 since for mysql5 we will not need it
cyrus-sasl-sql = SASL is the Simple Authentication and Security Layer, mysql5 will have in its own package installation

by looking at error we know that there is dependancy by other files so try to remove those files first
if you require pearl for mysql5 there are newer version of perl driver you need to install.
NOTE: I could have removed it with --nodeps parameter which i come to know later so you may try with this parameter as follows
rpm --nodeps --allmatches -e mysql-4.1.22-2.el4
rpm --nodeps --allmatches -e mysqlclient10-3.23.58-4.RHEL4.1


6. remove dependencies (pls check note above)
 
[root@RAJ ~]# rpm -e perl-DBD-MySQL-2.9004-3.1.centos4.i386
[root@RAJ ~]# rpm -e cyrus-sasl-sql-2.1.19-14.i386

7. now try again step 5 again (pls check note above)
 
[root@RAJ ~]# rpm -e mysql-4.1.22-2.el4
warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave

8. remove mysqlclient (pls check note above)
 
[root@RAJ ~]# rpm -e dovecot-0.99.14-1.1.el3.rf.i386
[root@RAJ ~]#
[root@RAJ ~]# rpm -e mysqlclient10-3.23.58-4.RHEL4.1

9. after this is done pls check data and binary folder of mysql is removed or not if not removed then rename it if you require them or can safely remove it

10. I have downloaded following rpm from mysql site
 
[root@RAJ installers]# ls -l
total 25864
-rw-r--r-- 1 root root 7256227 Aug 18 06:02 MySQL-client-community-5.1.37-0.rhel4.i386.rpm
-rw-r--r-- 1 root root 19179293 Aug 18 01:50 MySQL-server-community-5.1.37-0.rhel4.i386.rpm
[root@RAJ installers]# chmod 755 *

11. Install new version of mysql 5 server and client
 
[root@RAJ installers]# rpm -i MySQL-server-community-5_1.1.37-0.rhel4.i386.rpm
warning: MySQL-server-community-5_1.1.37-0.rhel4.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
090818 7:52:19 [Warning] Forcing shutdown of 2 plugins
090818 7:52:20 [Warning] Forcing shutdown of 2 plugins

It shows some more message on screen and automatically starts mysql server.
 
[root@RAJ installers]# rpm -i MySQL-client-community-5.1.37-0.rhel4.i386.rpm
warning: MySQL-client-community-5.1.37-0.rhel4.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5

this completes the installation of mysql server and clients
there are some post installation steps to be folllowed to configure mysql if needed
like setting up my.cnf file to /etc location or creating auto start script of mysql on start of server. etc.

12. check mysql version now
 
[root@RAJ Whitehedge]# mysql -V
mysql Ver 14.14 Distrib 5.1.37, for pc-linux-gnu (i686) using readline 5.1