首页 > 代码库 > MySQL 5.7.17 源码方式安装详细步骤
MySQL 5.7.17 源码方式安装详细步骤
一:操作系统环境和目录结构
[mysql@oracle11gtest ~]$ cat /etc/redhat-release
CentOS release 6.8 (Final)
[mysql@oracle11gtest ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 21G 18G 55% /
tmpfs 7.8G 68K 7.8G 1% /dev/shm
/dev/vdb1 1008G 169G 789G 18% /alidata1
二:下载
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17.tar.gz
官方安装文档地址
http://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html
三:创建用户:
[mysql@oracle11gtest ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 21G 18G 55% /
tmpfs 7.8G 68K 7.8G 1% /dev/shm
/dev/vdb1 1008G 169G 789G 18% /alidata1
因为我的测试环境是在阿里云上,alidata1目录下之前安装了oracle,现在还是在这个目录下安装mysql,所以我需要把mysql用户的组设置为ointall,目的是让mysql用户读写alidata1目录
useradd -g oinstall mysql
创建之后:
[mysql@oracle11gtest ~]$ id
uid=1201(mysql) gid=1000(oinstall) groups=1000(oinstall)
四:安装组件准备,有的组件操作系统里面可能已经存在了,忽略即可。
yum install gcc gcc-c++ -y
yum install -y ncurses-devel.x86_64
yum install -y cmake.x86_64
yum install -y libaio.x86_64
yum install -y bison.x86_64
yum install -y gcc-c++.x86_64
五:数据库目录规划
mysql软件目录: /usr/local/mysql
mysql数据目录:/alidata1/mysqldata/3306/data
mysql日志目录:/alidata1/mysqldata/3306
[mysql@oracle11gtest ~]$ mkdir -p /alidata1/mysqldata/{3306/{data,tmp,binlog},backup,scripts}
六:解压
[root@oracle11gtest mysqlsoftware]# tar -xzvf mysql-5.7.17.tar.gz
七:CMake
进入解压后的软件目录进行CMake,CMake的目的是生成makefile文件,为下一步编译做准备
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPILATION_COMMENT=’Mysqlma’ \
-DWITH_READLINE=ON \
-DSYSCONFDIR=/data/mysqldata/3306 \
-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock
遇到一个报错:
CMake Error at cmake/boost.cmake:81 (MESSAGE):
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=
This CMake script will look for boost in . 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/mysqlsoftware/mysql-5.7.17/CMakeFiles/CMakeOutput.log”.
See also “/root/mysqlsoftware/mysql-5.7.17/CMakeFiles/CMakeError.log”.
解决办法,参考我另一篇博文:http://blog.itpub.net/20893244/viewspace-2133137/
重新执行CMake,出现如下信息表示CMake通过:
— Configuring done
— Generating done
— Build files have been written to: /root/mysql-5.7.17
八:编译和安装,时间比较长需要耐心等待
[root@oracle11gtest mysql-5.7.17]# make & make install
九:配置my.cnf参数文件
在/etc/下创建my.cnf文件,加入如下参数,其他参数根据需要配置
[client]
port=3306
socket=/alidata1/mysql5717/data/mysql.sock
[mysqld]
port=3306
user=mysql
socket=/alidata1/mysql5717/data/mysql.sock
pid-file=/alidata1/mysql5717/data/mysql.pid
basedir=/usr/local/mysql5717
datadir=/alidata1/mysql5717/data/
tmpdir=/alidata1/mysql5717/tmp
……
十:初始化数据库
执行:
./mysqld –initialize –user=mysql –basedir=/usr/local/mysql –datadir=/alidata1/mysqldata/3306/data
在日志文件里会提示一个临时密码,记录这个密码
2017-02-07T01:50:22.772693Z 1 [Note] A temporary password is generated for root@localhost: /sxS7/15q
注意:5.7.6之前的版本需要用下面这条命令初始化
mysql_install_db
十一:安装ssl
执行:
./mysql_ssl_rsa_setup
十二:启动数据库
mysqld_safe –defaults-file=/data/mysqldata/3306/my.cnf &
启动之后查看日志有个error
2017-02-07T10:57:41.256534Z 0 [ERROR] SSL error: Unable to get private key from ‘server-key.pem’
解决办法看我另一个博客:http://blog.itpub.net/20893244/viewspace-2133191/
至此5.7.17就安装完成了。<h)
本文出自 “小屁孩儿” 博客,谢绝转载!
MySQL 5.7.17 源码方式安装详细步骤