Monday, November 3, 2014

How to install a MySQL using a tarball as source

Overview

This will give view an overview on how to install a MySQL using a tarball. This way of installation will also allow you to install multiple version of MySQL on the same version.

Software Download

  • The first step is to download a version that is on tar format instead of the RPM.On my side I'm using generic Linux 64 bit 5.5.40
  • The next step is to prepare your server so you can install MySQL
    • Create a user mysql:mysql
    • Create a filesystem /mysql/product/5.5.40 (MYSQL_HOME) but you can also create folders
    • create the folder $MYSQL_HOME/config (MYSQL_CONFIG)
    • create a small  filesystem /mysql1
    • Create a filesystem /mysql1/data (mysql1 is my instance) (MYSQL_DATA)
    • Create a filesystem /mysql1/logs (MYSQL_BINLOG)
    • Create a filesystem /mysql
    • Create /mysql/admin/mysql1 (MYSQL_ADMIN)
      • scripts
      • logs
      • socket
      • pid
      • backup 
    • create /mysql/admin/mysqld_safe/logs
    • create /mysql/admin
    • Once your filesystems and folders are created make sure you do the following 
      • chown -R mysql;mysql /mysql /mysql1
      • chmod -R 775 /mysql /mysql1
  • copy the .tar.gz file in /mysql/product/5.5.40
  • untar (tar -zxvf)  the content into /mysql/product/5.5.40
  •  At this point the software is installed

 Create the instance (mysql1)

  • create your my.cnf into $MYSQL_HOME/config (I use mysql_5.5.40.cnf)
Here is an exemple of my .cnf file
#############################################33
[mysqld_safe]
basedir=/mysql/product/5.5.36

ledir=/mysql/product/5.5.36/bin

[mysqld_multi]
mysqld=mysqld_safe
mysqladmin=/mysql/product/5.5.36/bin/mysqladmin
log=/mysql/admin/mysql_multi/logs/mysql_multi.log

[mysqld1]
basedir=/mysql/product/5.5.36datadir=/mysql1/data
log-bin=/mysql1/logs/log-bin
socket=/mysql/admin/mysql1/socket/mysql1.socket
pid-file=/mysql/admin/mysql1/pid/mysql1.pid
log-error=/mysql/admin/mysql1/noslog/mysql1-error.log
max_binlog_size=100M
binlog-format=MIXED
port=3307

expire_logs_days=5
default-storage-engine=innodb

server-id=5401
skip-slave-start

##################################

  •  connect as mysql
  • cd $MYSQL_HOME
  • ./scripts/mysql_install_db --defaults-file=$MYSQL_HOME/config/mysql_5.5.36.cnf --basedir=$MYSQL_HOME --datadir=/mysql1/data --user=mysql
  • Your instance is now ready to be started

Start your Application

  • cd $MYSQL_HOME
  • ./bin/mysqld_multi --defaults-file=$MYSQL_CONFIG/mysql_5.5.36.cnf start 1 
  • I highly suggest you run the $MYSQL_HOME/bin/mysql_secure installation 
To stop it
  • ./bin/mysqld_multi --defaults-file=$MYSQL_CONFIG/mysql_5.5.36.cnf stop 1

Note

I discover that there is a bug (
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
)
for some of the tools like mysqladmin or mysqlcheck.
even if you specify the location of the my.cnf with the --defaults-file option you will get an error about not finding /tmp/my.cnf
the solution
  • create a symbolic link 
    • ln -fs $MYSQL_HOME/config/mysql_5.5.36.cnf /tmp/my.cnf
    • run your command
    • if you do not have multiple instance you can leave otherwise remove it after
 

No comments:

Post a Comment