Install mysql-5.6 under CentOS 6.8

Install mysql-5.6 under CentOS 6.8

Installation Environment:

CentOS release 6.8 (Final) 

percona-server-5.6.29-76.2

Install dependent libraries and tools

yum -y install gcc gcc-c++ libgcrypt openssl openssl098e openssl-devel ncurses ncurses-devel make cmake g++ bison ncurses-libs libaio unzip readline-devel

yum -y install wget iproute iotop mtr perf dstat iftop

add mysql user

[root@Paul ~]# groupadd -g 306 mysql

[root@Paul ~]# useradd -g 306 -u 306 -s/sbin/nologin -M mysql

Add data directory and software installation directory

[root@Paul ~]# mkdir /data/mysql –pv

[root@Paul ~]#mkdir /root/software

[root@Paul ~]# mkdir /usr/local/mysql

[root@Paul ~]# chown -R mysql.mysql /usr/local/mysql

 

compile and install

[root@Paul ~]# cd /root/software

[root@Paul software]# wget

https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.29-76.2/source/tarball/percona-server-5.6.29-76.2.tar.gz

[root@Paul software]# tar xf percona-server-5.6.29-76.2.tar.gz

[root@Paul software]# cd percona-server-5.6.29-76.2

 

Configure mysql precompiled parameters

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql #Software installation directory

-DMYSQL_DATADIR=/data/mysql \ #Data directory

-DSYSCONFDIR=/etc/my.cnf\ #Configuration file

-DMYSQL_TCP_PORT=3306 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DENABLED_LOCAL_INFILE=1 -DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci -DENABLE_DTRACE=0\

-DWITH_EXTRA_CHARSETS=all

compile, install

[root@Paul percona-server-5.6.29-76.2]# make

[root@Paul percona-server-5.6.29-76.2]# make install

Modify group and owner

[root@Paul local]# chown -R mysql.mysql /usr/local/mysql

[root@Paul ~]# chown -R mysql.mysql /data/mysql

Initialize the system database

 [root@Paul mysql]#

/usr/local/mysql/scripts/mysql_install_db  --user=mysql --datadir=/data/mysql   

--basedir=/usr/local/mysql                    

Modify the configuration file

[root@Paul ~]# vim /etc/my.cnf

[mysqld]

datadir=/data/mysql #Data directory

user=mysql

log-bin=mysql-bin #log-bin file storage directory

basedir = /usr/local/mysql

character_set_server = utf8 #server level character set

default_storage_engine = InnoDB #default storage

innodb_buffer_pool_size = 4000M #The main function is to cache the index, data, and insert data of the  innodb table

explicit_defaults_for_timestamp = true #Enable query caching

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

[client]

socket=/tmp/mysql.sock

                                                    

Configure the mysqld service

root@Paul ~]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld

[root@Paul ~]# chmod +x /etc/rc.d/init.d/mysqld

[root@Paul ~]# chkconfig --add mysqld

[root@Paul ~]# chkconfig mysqld on

[root@Paul ~]# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf

[root@Paul ~]# ln -sv /usr/local/mysql/include /usr/include/mysqld

 

set mysql environment variable

[root@Paul ~]# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh

[root@Paul ~]# source /etc/profile.d/mysql.sh

 

Configuration help documentation

[root@Paul ~]# vim /etc/man.config

          MANPATH /usr/local/mysql/man

 

[root@Paul ~]# service mysqld start

Starting MySQL (Percona Server).                           [  OK  ]

 

Phenomenon

[root@Paul local]# mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

 

Solution

root@Paul local]# vim /etc/my.cnf

[client]

socket=/data/mysql/mysql.sock


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324922061&siteId=291194637