下载
点击下载[5.7.17.tar.gz]
上传到服务器
解压
tar xzf mysql-boost-5.7.17.tar.gz
创建数据存放目录
mkdir /data/mysql
创建mysql用户
useradd -s /sbin/nologin mysql
chown -R mysql:mysql /data/mysql
yum安装编译软件
yum install -y gcc gcc-c++ cmake ncurses ncurses-devel bison
编译
cd /root/mysql-5.7.17
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql57/ \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_BIG_TABLES=1 \
-DWITH_DEBUG=0
make
make install
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql57 Cmake预编译
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock MYSQL Socket通信文件位置
-DMYSQL_DATADIR=/data/mysql MYSQL数据存放路径
-DSYSCONFDIR=/etc 配置文件路径
-DMYSQL_USER=mysql MYSQL运行用户
-DMYSQL_TCP_PORT=3306 MYSQL监听端口
-DWITH_XTRADB_STORAGE_ENGINE=1 开启xtradb引擎支持
-DWITH_INNOBASE_STORAGE_ENGINE=1 开启innodb引擎支持
-DWITH_PARTITION_STORAGE_ENGINE=1 开启partition引擎支持
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 开启blackhole引擎支持
-DWITH_MYISAM_STORAGE_ENGINE=1 开启MyISAM引擎支持
-DWITH_READLINE=1 启用快捷键功能
-DENABLED_LOCAL_INFILE=1 允许从本地导入数据
-DWITH_EXTRA_CHARSETS=1 支持额外的字符集
-DDEFAULT_CHARSET=utf8 默认字符集UTF-8
-DDEFAULT_COLLATION=utf8_general_ci 检验字符
-DEXTRA_CHARSETS=all 安装所有扩展字符集
-DWITH_BIG_TABLES=1 将临时表存储在磁盘上
-DWITH_DEBUG=0 禁止调试模式支持
make 编译
make install 安装
预编译可能会报错-报错信息如下
CMake Error at cmake/boost.cmake:81 (MESSAGE):
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>
This CMake script will look for boost in <directory>. If it is not there,
it will download and unpack it (in that directory) for you.
If you are inside a firewall, you may need to use an http proxy:
export http_proxy=http://example.com:80
Call Stack (most recent call first):
cmake/boost.cmake:238 (COULD_NOT_FIND_BOOST)
CMakeLists.txt:455 (INCLUDE)
-- Configuring incomplete, errors occurred!
See also "/root/mysql-5.7.17/CMakeFiles/CMakeOutput.log".
See also "/root/mysql-5.7.17/CMakeFiles/CMakeError.log".
解决方法
点击下载[boost.1.59.0.tar.gz] #跳转后等待5秒,就开始下载了
1.在/usr/local下创建一个名为boost的目录
mkdir -p /usr/local/boost
2.进入这个新创建的目录然后下载boost
https://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
3.解压
mv boost_1_59_0.tar.gz /usr/local/boost/
cd /usr/local/boost/
tar -xzf boost_1_59_0.tar.gz
4.继续cmake,后面添加以下参数
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost/
这是完整的命令,上面都有 等它加载完后面有这句话就说明环境没问题了
开始编译
make
Scanning dependencies of target INFO_BIN
[ 0%] Built target INFO_BIN
Scanning dependencies of target INFO_SRC
[ 0%] Built target INFO_SRC
Scanning dependencies of target abi_check
[ 0%] Built target abi_check
Scanning dependencies of target zlib
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/adler32.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/compress.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/crc32.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/deflate.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/gzio.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/infback.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/inffast.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/inflate.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/inftrees.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/trees.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/uncompr.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/zutil.c.o
开始编译安装
make install
编辑配置文件
cd /etc/
cp my.cnf my.cnf.back
vim my.cnf
配置文件:
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
user = mysql
basedir = /usr/local/mysql57
datadir = /data/mysql/
pid-file = /data/mysql/mysql.pid
log_error = /data/mysql/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/mysql-slow.log
skip-external-locking
key_buffer_size = 32M
max_allowed_packet = 1024M
table_open_cache = 128
sort_buffer_size = 768K
net_buffer_length = 8K
read_buffer_size = 768K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 16
query_cache_size = 16M
tmp_table_size = 32M
performance_schema_max_table_instances = 1000
explicit_defaults_for_timestamp = true
初始化mysql
整个命令:
cd /usr/local/mysql57/bin/
./mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql57 --datadir=/data/mysql/
解释:
./mysqld --initialize-insecure
--user=mysql
--basedir=/usr/local/mysql57
--datadir=/data/mysql/
拷贝可执行配置文件
cd /usr/local/mysql57/support-files
cp mysql.server /etc/init.d/mysqld
启动mysql
service mysqld start
Starting MySQL. SUCCESS!
测试连接
cd /usr/local/mysql57/bin
./mysql -hlocalhost -uroot -p
最终结果
|