Question: How to install the MySQL RPM packages in a different location to allow multiple versions and/or avoid compromising your existing installation?
Install the RPM package(s)
You can use the –relocate option for the rpm command to specify the location where you want to install MySQL. Important also, is the –noscripts option, which makes sure the post-installation scripts are not run (they are executed manually later):
shell> rpm -ivh --relocate=/=/opt/mysql --nodeps \ --noscripts MySQL-server-x.x.x-x.rhelx.x86_64.rpm
Configure MySQL
The my.cnf file should at least contain the following:
[mysqld_safe] ledir = /opt/mysql/usr/sbin [mysqld] basedir = /opt/mysql/usr language=/opt/mysql/usr/share/mysql/english datadir = /var/lib/mysql
It should reflect the location where you installed MySQL.
Post installation
You need to manually run mysql_install_db, after making sure directories are created. Make sure the permission of the directories are correct.
shell> mkdir /var/lib/mysql shell> cd /opt/mysql/usr shell> ./bin/mysql_install_db --defaults-file=/etc/mysql/my.cnf \ --basedir=/opt/mysql/usr \ --datadir=/var/lib/mysql
You will probably need to do some extra steps depending on what you are trying to accomplish. An example is configuring the the dynamic linker (man ldconfig).