MYSQL5.7.16 编译安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MYSQL5.7.16 编译安装相关的知识,希望对你有一定的参考价值。
mysql编译安装
一、安装cmake https://cmake.org/download/
/**************************************************************************/
yum -y install wget
wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
tar xf cmake-3.5.2.tar.gz
cd cmake-3.5.2
yum install -y make gcc gcc-c++ ncurses-devel
./bootstrap
gmake
gmake install
/**************************************************************************/
卸载相关
/**************************************************************************/
find / -name libboost_random.so* //查看相关的boost版本库
rpm -qa boost //查看安装版本
rpm -qa boost* //查看相关的boost库
rpm -e --nodeps boost-1.53.0-25.el7.x86_64 //卸载boost
rpm -e --nodeps \
-boost-thread-1.53.0-25.el7.x86_64 \
-boost-regex-1.53.0-25.el7.x86_64 \
-boost-wave-1.53.0-25.el7.x86_64 \
-boost-locale-1.53.0-25.el7.x86_64 \
-boost-python-1.53.0-25.el7.x86_64 \
-boost-atomic-1.53.0-25.el7.x86_64 \
-boost-random-1.53.0-25.el7.x86_64 \
-boost-iostreams-1.53.0-25.el7.x86_64 \
-boost-test-1.53.0-25.el7.x86_64 \
-boost-system-1.53.0-25.el7.x86_64 \
-boost-filesystem-1.53.0-25.el7.x86_64 \
-boost-date-time-1.53.0-25.el7.x86_64 \
-boost-graph-1.53.0-25.el7.x86_64 \
-boost-timer-1.53.0-25.el7.x86_64 \
-boost-serialization-1.53.0-25.el7.x86_64 \
-boost-context-1.53.0-25.el7.x86_64 \
-boost-program-options-1.53.0-25.el7.x86_64 \
-boost-signals-1.53.0-25.el7.x86_64 \
-boost-math-1.53.0-25.el7.x86_64 \
-boost-devel-1.53.0-25.el7.x86_64
rpm -qa | grep mysql
rpm -qa | grep mariadb
rpm -e --nodeps boost-system-1.53.0-25.el7.x86_64
rpm -e --nodeps boost-thread-1.53.0-25.el7.x86_64
rpm -e mariadb-libs-5.5.47-1.el7_2.x86_64
rpm -e --nodeps mariadb-libs-5.5.47-1.el7_2.x86_64
/**************************************************************************/
依赖包安装
/**************************************************************************/
1)gcc、make、cmake
2)mysql依赖包支持语法分析的bison库和终端类GUI支持ncurses
yum install bison* -y
yum install ncurses* -y
yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel perl-Data-Dumper net-tools
/**************************************************************************/
安装boost
/**************************************************************************/
wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
tar zvxf boost_1_59_0.tar.gz
cd boost_1_59_0
./bootstrap.sh --with-libraries=system,filesystem,log,thread --with-toolset=gcc
./b2 toolset=gcc cxxflags="-std=c++11"
./b2 install --prefix=/usr/local/boost
cd ..
/**************************************************************************/
./bootstrap.sh
./b2
sudo ./b2 install
#默认安装在/usr/local/lib目录下;头文件在/usr/local/include/boost目录下;install后面可以加参数 --prefix=/usr 来设置安装路径
#如果提示boost版本不对应则卸载boost安装对应版本boost
/**************************************************************************/
cmake安装mysql
/**************************************************************************/
cmake \
-DCMAKE_INSTALL_PREFIX=/var/lib/mysql \
-DMYSQL_DATADIR=/var/lib/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_BOOST=/root/boost_1_59_0
make && make install
/**************************************************************************/
编译出错,执行如下操作,然后重新配置。
/**************************************************************************/
make clean
rm -rf CMakeCache.txt
/**************************************************************************/
1、创建用户
/**************************************************************************/
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
/**************************************************************************/
2、授权mysql数据库目录
/**************************************************************************/
chown -R mysql:mysql /var/lib/mysql
cd /var/lib/mysql
chown -R mysql .
chgrp -R mysql .
/**************************************************************************/
3、初始化mysql数据库
/**************************************************************************/
/var/lib/mysql/bin/mysqld \
--initialize \
--user=mysql \
--datadir=/var/lib/mysql/data
/**************************************************************************/
/home/data/mysql/bin/mysql_ssl_rsa_setup
chown -R root .
chown -R mysql data
/**************************************************************************/
添加相关服务/配置自启动
/**************************************************************************/
cp ./support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
chkconfig | grep mysql
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
/**************************************************************************/
拷贝相关服务到系统目录下
/**************************************************************************/
cd /home/data/mysql
cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
/**************************************************************************/
4、拷贝配置文件,修改配置文件
/**************************************************************************/
cp support-files/my-default.cnf /etc/my.cnf
[mysqld]
# These are commonly set, remove the # and set as required.
basedir = /var/lib/mysql
datadir = /var/lib/mysql /data
port = 3306
server_id = 2
socket =/var/lib/mysql/mysql.sock
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
/**************************************************************************/
拷贝启动文件并授权
/**************************************************************************/
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
/**************************************************************************/
启动数据库
/**************************************************************************/
/etc/init.d/mysqld start
/**************************************************************************/
登录数据库
/**************************************************************************/
/var/lib/mysql/bin/mysql -uroot -p
password:
/**************************************************************************/
/**************************************************************************/
firewall-cmd --zone=public --add-port=3306/tcp --permanent
yum -y install net-tools
/**************************************************************************/
修改root密码
/**************************************************************************/
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘[email protected]‘
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.12.146‘;
FLUSH PRIVILEGES;
CREATE USER ‘center‘@‘%‘ IDENTIFIED BY ‘[email protected]‘;
GRANT select ON *.* TO ‘center‘@‘%‘;
yum -y install net-tools
firewall-cmd --zone=public --add-port=8066/tcp --permanent
firewall-cmd --zone=public --add-port=3306/tcp --permanent
systemctl restart firewalld.service
/**************************************************************************/
wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
tar xf cmake-3.5.2.tar.gz
cd cmake-3.5.2
yum install -y make gcc gcc-c++ ncurses-devel
./bootstrap
gmake
gmake install
cd..
tar xvf boost_1_59_0.tar.gz
cd boost_1_59_0
./bootstrap.sh --with-libraries=system,filesystem,log,thread --with-toolset=gcc
./b2 toolset=gcc cxxflags="-std=c++11"5 ./b2 install --prefix=/usr/local/boost
/**************************************************************************/
以上为个人笔记总结,现已真实安装部署,转载请联系作者
以上是关于MYSQL5.7.16 编译安装的主要内容,如果未能解决你的问题,请参考以下文章
CentOS6.8编译安装Nginx1.10.2+MySQL5.7.16+PHP7.0.12
CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境