一、環(huán)境說明
(1)CentOS-7-x86_64,內(nèi)核版本
uname -r
3.10.0-693.el7.x86_64
(2)Mysql版本
(3)文件存放路徑
二、安裝前準(zhǔn)備
(1)配置權(quán)限
groupadd mysql
useradd -r -g mysql mysql
(2)創(chuàng)建安裝目錄
mkdir /usr/local/mysql #mysql安裝目錄
chown -R mysql:mysql /usr/local/mysql
mkdir /usr/local/mysql/dataconf #數(shù)據(jù)庫配置存放目錄
chown -R mysql:mysql /usr/local/mysql/dataconf
mkdir /usr/local/mysql/sock #運行mysql時mysql.sock存放目錄
chown -R mysql:mysql /usr/local/mysql/sock
mkdir /var/log/mysql #創(chuàng)建日志存放目錄
touch /var/log/mysql/mysql.log
chown -R mysql:mysql /var/log/mysql/mysql.log
touch /usr/local/mysql/my.cnf #創(chuàng)建mysql配置文件
三、安裝編譯環(huán)境
yum install readline-devel git gcc gcc-c++ make cmake bison bison-devel ncurses-devel libaio-devel perl zlib1g-dev autoconf
四、編譯安裝percona
cd /home/soft/
tar zxvf percona-server-5.6.29-76.2.tar.gz
cd percona-server-5.6.29-76.2
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql #需要使用cmake進(jìn)行安裝,這里表示的是文件安裝目錄
-DSYSCONFDIR=/usr/local/mysql #存放配置文件的目錄
-DMYSQL_DATADIR=/usr/local/mysql/dataconf #存放數(shù)據(jù)庫的目錄
-DMYSQL_UNIX_ADDR=/usr/local/mysql/sock/mysqld.sock #存放mysql.sock文件的目錄
-DMYSQL_TCP_PORT=3306 -DWITH_MYISAM_STORAGE_ENGINE=1 #配置端口
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8 #配置默認(rèn)的字符編碼格式
-DDEFAULT_COLLATION=utf8_general_ci
-DENABLED_LOCAL_INFILE=1
-DWITH_EDITLINE=bundled
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DBUILD_CONFIG=mysql_release
-DFEATURE_SET=community
-DWITH_EMBEDDED_SERVER=OFF
之后,繼續(xù)編譯安裝。
make -j 8 #大概需要30-40分鐘左右。如果報錯,請使用make clean , rm -rf CMakeCache.txt
make install
五、配置Percona參數(shù)
cat /usr/local/mysql/my.cnf
[mysqld]
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
explicit_defaults_for_timestamp=true
federated
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
basedir=/usr/local/mysql
datadir=/usr/local/mysql/dataconf
port=3306
socket=/usr/local/mysql/sock/mysql.sock
symbolic-links=0
character_set_server=utf8
pid-file=/usr/local/mysql/mysql.pid
skip-grant-tables
[mysqld_safe]
log-error=/var/log/mysql/mysql.log
pid-file=/usr/local/mysql/mysql.pid
socket=/usr/local/mysql/sock/mysql.sock
[client]
socket=/usr/local/mysql/mysql.sock
[mysql.server]
user=mysql
basedir=/usr/local/mysql
socket=/usr/local/mysql/sock/mysql.sock
[mysql]
socket=/usr/local/mysql/sock/mysql.sock
六、配置Mysql訪問權(quán)限
chown -R mysql:mysql /usr/local/mysql/bin
chown -R mysql:mysql /usr/local/mysql/mysql.pid
七、初始化Mysql服務(wù)器
/usr/local/mysql/scripts/mysql_install_db --defaults-file=/usr/local/mysql/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/dataconf --user=mysql
八、配置環(huán)境變量
為了能直接調(diào)用mysql命令,需要配置環(huán)境變量
vi /etc/profile
在/etc/profile文件末尾添加
export PATH=/usr/local/mysql/bin:$PATH
使環(huán)境變量立即生效
source /etc/profile
九、配置啟動腳本
cp /home/soft/percona-server-5.6.29-76.2/support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig mysql on
service mysql start/stop
十、后言
此方法我也不知道為什么在CentOS7里面安裝之后可以用,在Debian服務(wù)器里面無法進(jìn)行編譯安裝使用。另外在使用的過程中,有時候可能也需要Percona-Server-client的支持。針對這個問題,可以使用以下方法解決:將文件上傳到/home/soft/目錄下,然后進(jìn)行安裝。安裝方法如下:
rpm -ivh Percona-Server-shared-compat-5.5.35-rel33.0.611.rhel6.x86_64.rpm
rpm -ivh Percona-Server-shared-55-5.5.35-rel33.0.611.rhel6.x86_64.rpm
rpm -ivh Percona-Server-devel-55-5.5.35-rel33.0.611.rhel6.x86_64.rpm
rpm -ivh Percona-Server-client-55-5.5.35-rel33.0.611.rhel6.x86_64.rpm
或者使用rpm -ivh * 即可安裝
您可能感興趣的文章:- CentOS 6.4安裝配置LAMP服務(wù)器(Apache+PHP5+MySQL)
- CentOS+Nginx+PHP+MySQL詳細(xì)配置(圖解)
- centos6利用yum安裝php mysql gd的步驟
- CentOS 6.4安裝配置LNMP服務(wù)器(Nginx+PHP+MySQL)
- 在CentOS上MySQL數(shù)據(jù)庫服務(wù)器配置方法
- CentOS 7下MySQL服務(wù)啟動失敗的快速解決方法
- CentOS 5.5下安裝MySQL 5.5全過程分享
- centos 7安裝mysql5.5和安裝 mariadb使用的命令
- Centos7 下mysql重新啟動MariaDB篇
- CentOS 6.5下yum安裝 MySQL-5.5全過程圖文教程