You are on page 1of 3

Step 1 Make the directories or folders you need

mkdir -p /u01/mysql
mkdir -p /u01/mysql/data
mkdir -p /u01/mysql/logs
mkdir -p /u01/mysql/tmp
mkdir -p /u01/mysql/backups

Step 2 Download the software


cd /u01
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.31-1.el6.x86_64.rpm-
bundle.tar
tar -xvf MySQL-5.6.31-1.el6.x86_64.rpm-bundle.tar

Use Yum to remove any older mysql installation

rpm -qa | grep -i mysql


yum remove mysql-5.1.71-1.el6
yum remove mysql-server-5.1.71-1.el6
yum remove mysql-libs-5.1.71-1.el6

Install the new packages

rpm -ivh MySQL-shared-5.6.31-1.el6.x86_64.rpm


rpm -ivh MySQL-client-5.6.31-1.el6.x86_64.rpm
rpm -ivh MySQL-shared-compat-5.6.31-1.el6.x86_64.rpm
rpm -ivh MySQL-server-5.6.31-1.el6.x86_64.rpm

Create a my.cnf file and configure it the way you want


vi my.cnf and paste the sample configuration file information
ls -l /etc/my.cnf
cp /etc/my.cnf /u01/mysql/
ls -l /u01/mysql/my.cnf
remove the /etc/my.cnf --> rm /etc/my.cnf
ln -s /u01/mysql/my.cnf /etc/my.cnf
ls -l /etc/my.cnf
ls -l /usr/my.cnf
rm /usr/my.cnf

Set permissions of the directories to ensure they are owned by mysql


ls -l /u01/mysql/
chown -R mysql:mysql /u01/mysql/
ls -l /u01/mysql/

Create the initial mysql databases and logfiles:

Install resolveip: yum install resolveip

/usr/bin/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf --keep-my-


cnf

Remove default mysql install directory and symlink to new mysql data directory:

rm -rf /var/lib/mysql/ ; ln -s /u01/mysql/data/ /var/lib/mysql

Remove the default random mysql password generated by the RPM installation:
ls -l /root/.mysql_secret
rm /root/.mysql_secret
ls -l /root/.mysql_secret

Start MySQL and Configure Users

Now we will start the MySQL service and configure the root user account:

cd /usr ; /usr/bin/mysqld_safe &

or use /etc/init.d/mysql start

but selinux stops mysql starting.


Try

/usr/sbin/setenforce Permissive

before you start mysql with

/etc/init.d/mysql start

log in mysql by typing command:


mysql

Perform security hardening from within the MySQL CLI, including passwords that
conform to Acxiom Corporate Security Policy:

DELETE FROM mysql.user WHERE user="";


DELETE FROM mysql.user WHERE user="root" AND host <> "localhost";
UPDATE mysql.user SET Password=PASSWORD('new-password-here') WHERE User="root";
FLUSH PRIVILEGES;

Alternatively you can run mysql_secure_installation to tighten the security

Note: /usr/sbin/setenforce Permissive


This will only work temporarily, becuase a reboot will cause /etc/init.d/mysql
start to not work when trying to start mysql
So set setenforce to Permissive in the SELinux config file

Permanent Change

The setenforce command does not require a server reboot but its also not going to
survive a reboot. To make the change permanent, ask your system admin to edit
/etc/selinux/config to set SELINUX=permissive
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

Now make sure mysql start automatically when computer boots:


# chkconfig --add mysql
# chkconfig --list mysql

Note: remember to edit /etc/selinux/config to set SELINUX=permissive

Temporary Fix

> /usr/sbin/getenforce;
Enforcing

> sudo /usr/sbin/setenforce 0 ;


> /usr/sbin/getenforce;
Permissive

Read https://oramanageability.com/tag/usrsbinsetenforce/

/usr/sbin/setenforce Permissive is the same as running /usr/sbin/setenforce 0

/usr/sbin/setenforce enforcing is the same as running /usr/sbin/setenforce 1

You might also like