• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How To Install MySQL RPM packages in a different location to allow multiple versions (versions < 5.6.10)

by admin

Question: How to install the MySQL RPM packages in a different location to allow multiple versions and/or avoid compromising your existing installation?

Note that it is generally not recommended to install the RPM package of MySQL in a different location.

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).

Note: It is important to note that this approach does not work on MySQL 5.6.10 or later. On later versions a generic install is recommended if you need a non-default install.

Filed Under: mysql

Some more articles you might also be interested in …

  1. MySQL 8.0 : Persisted Variables
  2. How to Rollback RPM Upgrade of the MySQL Server
  3. How to gather information on the MySQL 8 Roles and Privileges assigned to a user without using SHOW GRANTS
  4. Multi-Versioning in MySQL Database
  5. MySQL: Identify what user and thread are holding on to a meta data lock that is preventing other queries from running
  6. How to Restore a Specific Database or Table (MySQL)
  7. MySQL Fails to Start Using systemctl On systemd Linux Distributions
  8. Understanding MySQL Storage Engines – MyISAM, MEMORY, BLACKHOLE and ARCHIVE
  9. How to take Logical Backups on a MySQL Replication Slave using shell script
  10. Configure MySQL Router to Auto Restart of Failure using systemd

You May Also Like

Primary Sidebar

Recent Posts

  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found
  • macof: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright