MySQL5.7.20源码安装

一、 获取MySQL5.7.20源码安装包,并上传至服务器
MySQL官网下载地址:https://dev.mysql.com/downloads/mysql/
下载版本:mysql-boost-5.7.20.tar.gz此版本带有boost。
二、 安装依赖包
[root@xjfw3 ~]# yum -y install gcc gcc-c++ ncurses ncurses-devel cmake
三、 操作系统环境和目录结构
[root@xjfw3 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.3 (Santiago)
[root@xjfw3 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_local-lv_root
                       20G  5.1G   14G  28% /
tmpfs                  16G   76K   16G   1% /dev/shm
/dev/mapper/vg_local-lv_app
                       40G  176M   38G   1% /app
/dev/sda1             485M   55M  405M  12% /boot
/dev/mapper/vg_local-lv_home
                      4.0G  137M  3.7G   4% /home
/dev/sdb1             394G  2.8G  371G   1% /weblogic
四、添加mysql禁止登录的用户及目录规划
[root@xjfw3 ~]# groupadd mysql
[root@xjfw3 ~]# useradd -r -g mysql -s /sbin/nologin mysql
MySQL数据库目录划分:
mysql软件目录: /weblogic/mysql/mysql
mysql数据目录:/weblogic/mysql/datadir
mysql日志目录:/weblogic/mysql/logdir
[root@xjfw3 ~]# mkdir -p /weblogic/mysql/mysql
[root@xjfw3 ~]# mkdir -p /weblogic/mysql/datadir
[root@xjfw3 ~]# mkdir -p /weblogic/mysql/logdi
[root@xjfw3 ~]# cd /weblogic/
[root@xjfw3 weblogic]# chown -R mysql.mysql mysql/
五、解压MySQL并编译安装
1、解压Mysql
[root@xjfw3 ~]# cd /root
[root@xjfw3 ~]# ls mysql-boost-5.7.20.tar.gz 
mysql-boost-5.7.20.tar.gz
[root@xjfw3 ~]# tar -xvf mysql-boost-5.7.20.tar.gz 
2、编译安装
[root@xjfw3 ~]# 
[root@xjfw3 ~]# cd /root/mysql-5.7.20/
[root@xjfw3 mysql-5.7.20]# cmake . \
>  -DCMAKE_INSTALL_PREFIX=/weblogic/mysql/mysql \
>  -DMYSQL_DATADIR=/weblogic/mysql/datadir \
>  -DDOWNLOAD_BOOST=1 \
>  -DWITH_BOOST=/root/mysql-5.7.20/boost \
>  -DSYSCONFDIR=/etc \
>  -DWITH_INNOBASE_STORAGE_ENGINE=1 \
>  -DWITH_PARTITION_STORAGE_ENGINE=1 \
>  -DWITH_FEDERATED_STORAGE_ENGINE=1 \
>  -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
>  -DWITH_MYISAM_STORAGE_ENGINE=1 \
>  -DENABLED_LOCAL_INFILE=1 \
>  -DENABLE_DTRACE=0 \
>  -DDEFAULT_CHARSET=utf8 \
>  -DDEFAULT_COLLATION=utf8_general_ci \
>  -DWITH_EMBEDDED_SERVER=1
[root@xjfw3 mysql-5.7.20]# make & make install
(此过程时间比较长)
六、配置my.cnf文件
[root@xjfw3 mysql]# vi /etc/my.cnf

[client]
port=3306
socket=/weblogic/mysql/datadir/mysql.sock
default-character-set=utf8
[mysqld]
port=3306
user=mysql
socket=/weblogic/mysql/datadir/mysql.sock
pid-file=/weblogic/mysql/datadir/mysql.pid
basedir=/weblogic/mysql/mysql
datadir=/weblogic/mysql/datadir
tmpdir=/weblogic/mysql/tmpdir
character-set-server=utf8
log_error=/weblogic/mysql/logdir/mysql.err

server-id=2
log_bin=/weblogic/mysql/logdir/binlog

general_log_file=/weblogic/mysql/logdir/general_log
general_log=1

slow_query_log=ON
long_query_time=2
slow_query_log_file=/weblogic/mysql/logdir/query_log
log_queries_not_using_indexes=ON

"/etc/my.cnf" [New] 25L, 605C written
[root@xjfw3 mysql]# 
七、初始化数据库
[root@xjfw3 datadir]# cd /weblogic/mysql/mysql/bin
[root@xjfw3 bin]# ./mysqld --initialize-insecure --user=mysql --basedir=/weblogic/mysql/mysql --datadir=/weblogic/mysql/datadir/data
八、安装ssl,可指定文件生成路径,默认为DATA里面
[root@xjfw3 datadir]# cd /weblogic/mysql/mysql/bin
[root@xjfw3 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'
-----
[root@gsxjfw3 bin]# 
九、启动数据库
[root@xjfw3 ~]# cp /weblogic/mysql/mysql/support-files/mysql.server /etc/init.d/msyqld
[root@xjfw3 support-files]# /etc/init.d/mysqld start
Starting MySQL.[  OK  ]
[root@xjfw3 ~]# ps -ef | grep mysql
root     14979     1  0 19:57 pts/2    00:00:00 /bin/sh /weblogic/mysql/mysql/bin/mysqld_safe --datadir=/weblogic/mysql/datadir/data --pid-file=/weblogic/mysql/datadir/mysql.pid
mysql    15278 14979  0 19:57 pts/2    00:00:00 /weblogic/mysql/mysql/bin/mysqld --basedir=/weblogic/mysql/mysql --datadir=/weblogic/mysql/datadir/data --plugin-dir=/weblogic/mysql/mysql/lib/plugin --user=mysql --log-error=/weblogic/mysql/logdir/mysql.err --pid-file=/weblogic/mysql/datadir/mysql.pid --socket=/weblogic/mysql/datadir/mysql.sock --port=3306
root     15397 14855  0 20:04 pts/2    00:00:00 grep mysql
[root@xjfw3 ~]# 
十、登录数据库并修改密码
[root@xjfw3 ~]# /weblogic/mysql/mysql/bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.20-log Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> alter user 'root'@'localhost' identified by 'mysql';
Query OK, 0 rows affected (0.00 sec)

mysql> 
十一、修改环境变量
[root@xjfw3 ~]# vi /etc/profile
PATH=/weblogic/mysql/mysql/bin:/weblogic/mysql/mysql/lib:$PATH
export PATH
"/etc/profile" 80L, 1868C written
[root@xjfw3 ~]# source /etc/profile
[root@xjfw3 ~]# 

至此Mysql安装完毕,源码安装过于繁琐。建议 使用官方编译好的二进制文件安装









  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值