Software Collections:MySQL

From SME Server
Jump to: navigation, search
Warning.png Work in Progress:
This page is a Work in Progress. The contents off this page may be in flux, please have a look at this page history the to see list of changes.

Warning.png Warning:
if you want an easy way to install and configure mysql55 on SME9 : try the contrib : MySQL55

Softwarecollections.png

Mysql.png

Installing and running MySQL via Software collections

Software Collections has been introduced by Redhat as a safe way to run selective applications on Redhat based distributions in an isolated environment (separate directory), thus not effecting the base installation of the OS. This provides the possibility to e.g. test an application, install a higher version then the version installed by the base system (e.g. PHP), or temporarily use an application.

Software Collections applications can be started at boot as a system service, manually or in a specific shell.

MySQL

Installation

To be able to install an application from the Software Collections, one must install software collections first. Please see Software collections on how to install this.


Required repository

After installing Software Collections, the scl repository for MySQL has to be added to the yum repositories. Please see here on how the enable the scl-mysql55 repository.


Install application

After installing the scl-mysql55 repository, MySQL can be installed by issuing the following command:

yum install mysql55 --enablrepo=scl-mysql55

Once installed, the application is installed on your SME Server at /opt/rh/mysql55- as an isolated environment for the application.

Only 1 service script has been installed on your base SME Server which is /etc/rc.d/init.d/mysql55-mysqld. This script will start and stop the installed application.


Test installed application

Once MySQL has been installed, you can check if it is correctly installed by issuing:

scl -l

which will provide you a listing of all applications that are available on your system installed via Software Collections.

A simple man page about the installed application is now available via:

scl enable mysql55 'man mysql55'

press 'q' to leave the man page

Changes to my.cnf configuration file

Now that the scl version of MySQL is installed, the /opt/rh/mysql55/root/etc/my.cnf configuration file has to be adjusted so that the scl version of MySQL does not interfere with the standard version of MySQL. The default port of MySQL is 3306, for the scl version of MySQL we will use port 3307, but this can be any port of your choosing. The default socket file is /var/lib/mysql/mysql.sock, for the scl version of MySQL we will use /var/lib/mysql/mysql55.sock.

/opt/rh/mysql55/root/etc/my.cnf will then be:

[mysqld]
datadir=/opt/rh/mysql55/root/var/lib/mysql
socket=/var/lib/mysql/mysql55.sock
port=3307
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under different user or group, 
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mysql55-mysqld.log
pid-file=/opt/rh/mysql55/root/var/run/mysqld/mysqld.pid

mysql command line access

To access the new instance of mysql from the command line you need to specify the appropriate connect string in the command line, using one or the other of these:

mysql --socket=/var/lib/mysql/mysql55.sock


Start/Stop MySQL

MySQL is now installed and can be started and stopped manually via:

/etc/rc.d/init.d/mysql55-mysqld start

and

/etc/rc.d/init.d/mysql55-mysqld stop


Start/Stop MySQL as a system service

Issue the following commands as root:

ln -s /etc/rc.d/init.d/e-smith-service /etc/rc7.d/S99mysql55-mysqld
chkconfig mysql55-mysqld on
config set mysql55-mysqld service
config setprop mysql55-mysqld status enabled

The application will now automatically start at boot time as a system service.


Configure private/public access

You will need to make some additional adjustments if your SME Server is hosting the application and is being accessed by other hosts either locally (LAN) or remotely (WAN). Privileges for the ports and access privileges need to be set. Use the following commands to modify the configuration. This example uses port 3307 as the port to connect to MySQ; you may need to use a different port for your specific set up.

config setprop mysql55-mysqld TCPPort 3307
config setprop mysql55-mysqld UDPPort 3307
config setprop mysql55-mysqld access private

Follow that with event signals to update the SME configuration.

signal-event remoteaccess-update

You can toggle between private and public access by changing the value of the "mysql55-mysqld access" property. Remember to follow any change with the remoteaccess-update command.

Other articles in this category

PHP Software Collections, Software Collections, Software Collections Repositories, Software Collections:MariaDB, Software Collections:MongoDB, Software Collections:MySQL, Software Collections:MySQL55, Software Collections:MySQL57, Software Collections:Nodejs, Software Collections:PHP, Software Collections:PostgreSQL, Software Collections:Python, Software Collections:Ruby on Rails