MySQL5.7.18 源码安装详细步骤

原创 2017年05月08日 17:51:40


MySQL5.7.18 源码安装详细步骤


一:操作系统环境和目录结构


[root@mysql3 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.7 (Santiago)
[root@mysql3 ~]# 
[root@mysql3 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        16G  5.4G  9.6G  36% /
tmpfs           932M     0  932M   0% /dev/shm
/dev/sda1        79G   56M   75G   1% /data



注意,在安装操作系统时,把cmake装上。

二、获取MySQL5.7.18源码安装包,并上传至服务器。


MySQL官网下载地址:https://dev.mysql.com/downloads/mysql/

下载版本:mysql-boost-5.7.18.tar.gz 此版本带有boost。


三、创建MySQL用户以及MySQL数据库目录划分


创建MySQL用户:

groupadd -g 701 mysql

useradd -M -g mysql -u 1101 -s /sbin/nologin  mysql  #建立mysql账号,-M不建立家目录,-s自动以shell为/sbin/nologin账号不能登录


(如若已存在MySQL用户,在确定不影响其他功能的情况下,可将之删除,并重建)


MySQL数据库目录划分:

mysql软件目录: /data/mysql/installdir
mysql数据目录:/data/mysql/datadir/3306/data
mysql日志目录:/data/mysql/logdir/3306/{bin_log,general_log,error_log,query_log}

[root@mysql3 ~]# mkdir -p /data/mysql/installdir
[root@mysql3 ~]# mkdir -p /data/mysql/datadir/3306/data
[root@mysql3 ~]# mkdir -p /data/mysql/logdir/3306/{bin_log,general_log,error_log,query_log}

 [root@mysql3 data]# pwd
/data
[root@mysql3 data]# chown -R mysql:mysql mysql/


四、解压MySQL并编译并安装


1.解压MySQL安装文件:

[root@mysql3 src]# pwd
/data/mysql/src
[root@mysql3 src]# ls
mysql-boost-5.7.18.tar.gz
[root@mysql3 src]# tar -xvf mysql-boost-5.7.18.tar.gz


2.进入解压后的软件目录进行CMake,CMake的目的是生成makefile文件,为下一步编译做准备
如果之前编译不成功,请执行以下命令:
make clean
rm CMakeCache.txt


进入解压后的目录:cd /data/mysql/src/mysql-5.7.18

cmake . -DCMAKE_INSTALL_PREFIX=/data/mysql/installdir \
-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='MySQL wenyi.huang' \
-DWITH_READLINE=ON \
-DWITH_BOOST=/data/mysql/src/mysql-5.7.18/boost \
-DSYSCONFDIR=/data/mysql/datadir/3306/data \
-DMYSQL_UNIX_ADDR=/data/mysql/datadir/3306/data/mysql.sock


[root@mysql3 mysql-5.7.18]# cmake . -DCMAKE_INSTALL_PREFIX=/data/mysql/installdir  -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='MySQL wenyi.huang'  -DWITH_READLINE=ON  -DWITH_BOOST=/data/mysql/src/mysql-5.7.18/boost  -DSYSCONFDIR=/data/mysql/datadir/3306/data  -DMYSQL_UNIX_ADDR=/data/mysql/datadir/3306/data/mysql.sock


  
  注意:关于cmake编译的参数可以到官网学习。https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html



3.编译并安装

cd /data/mysql/src/mysql-5.7.18

make & make install

(注意:这步需要1.5个小时左右,请耐心等待)

4.配置my.cnf文件

vi /etc/my.cnf
[client]
port=3306
socket=/data/mysql/datadir/3306/data/mysql.sock

[mysqld]
port=3306
user=mysql
socket=/data/mysql/datadir/3306/data/mysql.sock
pid-file=/data/mysql/datadir/3306/data/mysql.pid
basedir=/data/mysql/installdir
datadir=/data/mysql/datadir/3306/data
tmpdir=/data/mysql/tmpdir

log_error=/data/mysql/logdir/3306/error_log/mysql3.err

server-id = 1
log_bin = /data/mysql/logdir/3306/bin_log/binlog

general_log_file=/data/mysql/logdir/3306/general_log
general_log      = 1

slow_query_log = ON
long_query_time = 2
slow_query_log_file = /data/mysql/logdir/3306/query_log
log_queries_not_using_indexes = ON

5.初始化数据库

cd /data/mysql/installdir/bin

./mysqld --initialize --user=mysql --basedir=/data/mysql/installdir --datadir=/data/mysql/datadir/3306/data

[root@mysql3 bin]# ./mysqld --initialize --user=mysql --basedir=/data/mysql/installdir --datadir=/data/mysql/datadir/3306/data
2017-05-08T13:53:02.019530Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-05-08T13:53:03.084456Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-05-08T13:53:03.192605Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-05-08T13:53:03.335050Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a7cd6864-33f5-11e7-b4e5-000c29d7ab18.
2017-05-08T13:53:03.338753Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-05-08T13:53:03.341861Z 1 [Note] A temporary password is generated for root@localhost: hTdE.-th:5.g

6.安装ssl,可指定文件生成路径,默认为DATA里面

 cd /data/mysql/installdir/bin
 
./mysql_ssl_rsa_setup

[root@mysql3 bin]# ./mysql_ssl_rsa_setup
Generating a 2048 bit RSA private key
.........................+++
..................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
..............................................................................+++
...............................................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
........+++
................+++
writing new private key to 'client-key.pem'

生成的文件在/data/mysql/datadir/3306/data目录下


7.启动数据库

./mysqld_safe --defaults-file=/etc/my.cnf &

或 
cp /data/mysql/installdir/support-files/mysql.server /etc/init.d/mysqld

/etc/init.d/mysqld start

8.登陆客户端,建库建表建用户。

./mysql -uroot -p   hTdE.-th:5.g

alter user 'root'@'localhost' identified by 'root@20170508';

CREATE DATABASE HWYDB DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
use HWYDB;
create table hwy( nid int not null auto_increment primary key, name varchar(32) not null, email varchar(64) not null, extra text, unique ix_name (name) );

grant SELECT,INSERT,UPDATE,DELETE on HWYDB.* to 'dbadmin'@'172.16.115.%' identified by 'dbadmin@20170508';

至此,MySQL5.7.18源码安装完成!


版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Hwh1231/article/details/71426844

mysql-5.7.20 源码安装

运行环境: Ubuntu 16.04.3 LTS 1、添加mysql用户组并添加mysql用户,并且不允许登录 groupadd mysql useradd -r -g mysql -s /bi...
  • Just_shunjian
  • Just_shunjian
  • 2017-11-01 14:40:47
  • 2078

MySQL5.7.13源码编译安装与配置

原文链接:http://blog.csdn.net/xyang81/article/details/51792144安装环境:CentOS7 64位 MINI版官网源码编译安装文档:http://de...
  • xyang81
  • xyang81
  • 2016-07-01 01:09:00
  • 21360

MySQL 5.7.10最新版本源代码安装详细过程

1,下载地址:安装包下载地址:http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.10.tar.gz可以wget下载,也可以在pc本地网页上下...
  • mchdba
  • mchdba
  • 2015-12-18 21:04:01
  • 19622

Linux源码安装mysql 5.6.12 (cmake编译)

1.安装make编译器(默认系统自带) 下载地址:http://www.gnu.org/software/make/ [c-sharp] view plaincopyprint? tar ...
  • zqtsx
  • zqtsx
  • 2013-07-19 12:34:51
  • 30550

Linux下源码安装MySQL5.6.30

环境简介 linux :cenos 6.5 mysql版本:mySQL5.6.30 Mysql5.6.30安装与mySQL5.1安装还是有一些区别了,需要使用cmake进行安装信息的配置。据说M...
  • hsd2012
  • hsd2012
  • 2016-04-24 11:16:32
  • 7445

Linux CentOS6.5下编译安装MySQL 5.6.16【给力详细教程】

一、编译安装MySQL前的准备工作 安装编译源码所需的工具和库 yum install gcc gcc-c++ ncurses-devel perl安装cmake,从http://www.cmak...
  • wendi_0506
  • wendi_0506
  • 2014-09-22 16:49:01
  • 124241

MySQL5.7.20源码安装

一、获取MySQL5.7.20源码安装包,并上传至服务器 MySQL官网下载地址:https://dev.mysql.com/downloads/mysql/ 下载版本:mysql-boost-5...
  • fxnawm
  • fxnawm
  • 2017-11-10 10:44:12
  • 2220

mysql5.7编译安装

1.      安装库文件 安装编译代码需要的包 shell>yum -y install make gcc-c++ bisonncurses-devel #Set timezone(设置服务...
  • louishu_hu
  • louishu_hu
  • 2016-06-13 11:14:03
  • 1141

MySQL5.7的安装步骤

mysql-installer-community-5.7.9.1各版本相关说明: mysql-installer-web-community-5.7.9.0 : 有web标识的表示在线安装; m...
  • weiguolong0306
  • weiguolong0306
  • 2015-11-19 10:10:24
  • 26028

linux下mysql5.7.11源码安装

  • 2016年03月15日 11:42
  • 3KB
  • 下载
收藏助手
不良信息举报
您举报文章:MySQL5.7.18 源码安装详细步骤
举报原因:
原因补充:

(最多只允许输入30个字)