• 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. Configuring mysqld to log slow queries
  2. MySQL Shell: Using External Python Modules
  3. MySQL Cluster requirements to avoid Single Point of Failure
  4. Which Ports are Used by mysqld, ndb_mgmd, and ndbd/ndbmtd in a MySQL Cluster Installation
  5. Understanding mysqlcheck and myisamchk utilities
  6. Troubleshooting MySQL Query hung – “Waiting for Table Flush”
  7. MySQL : How To Find the Slowest Queries
  8. Recommended Configuration of the MySQL Performance Schema
  9. Examples of mysqldump partial backups
  10. MySQL Enterprise Backup (MEB): Lock the Tables While Making the Backup?

You May Also Like

Primary Sidebar

Recent Posts

  • qtchooser Command Examples in Linux
  • qtchooser: command not found
  • qsub Command Examples in Linux
  • qsub: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright