安装mysql5.7.20编译版_2019-06-19 编译安装MySQL5.7.20步骤

环境:已安装好系统版本CentOS7.4,虚拟机内存4G+8核i7 CPU

1.安装准备

源码包下载以及解压:

cd /tmp

wget https://downloads.mysql.com/archives/get/file/mysql-boost-5.7.20.tar.gz

tar xf mysql-boost-5.7.20.tar.gz

cd mysql-boost-5.7.20/ && mkdir debug && cd debug

安装mysql编译相关插件&&创建data目录

yum install bison cmake libaio-devel ncurses-devel -y

mkdir /data/mysql -p

2.编译安装mysql

cmake .. -DBUILD_CONFIG=mysql_release \

-DINSTALL_LAYOUT=STANDALONE \

-DCMAKE_BUILD_TYPE=RelWithDebInfo \

-DENABLE_DTRACE=OFF \

-DWITH_EMBEDDED_SERVER=1 \

-DWITH_INNODB_MEMCACHED=ON \

-DWITH_SSL=bundled \

-DWITH_ZLIB=system \

-DWITH_PAM=ON \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DINSTALL_PLUGINDIR="/usr/local/mysql/lib/plugin" \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_EDITLINE=bundled -DFEATURE_SET=community \

-DWITH_DEBUG=off -DWITH_BOOST=../boost/boost_1_59_0 \

-DSYSCONFDIR=/etc -DMYSQL_DATADIR=/data/mysql \

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

-DENABLED_LOCAL_INFILE=ON

看到 -- Configuring done -- Generating done代表编译完成且没有错误

注意:忽略警告,出现警告没有影响。

下面正式开始make编译(这里可以打开30个线程提高速度)以及安装mysql文件

make -j12 && make install

[100%] Built target mysql_client_test_embedded

-- Installing: /usr/local/mysql/support-files/mysql.server

看到以上信息证明编译和安装完成并且没有错误出现。

3.创建配置文件

cat >>/etc/mysql.cnf<

[mysqld]

user=mysql

basedir=/usr/local/mysql

datadir=/data/mysql

server_id=1

port=3306

socket=/tmp/mysql.sock

[mysql]

socket=/tmp/mysql.sock

prompt=mysql [\\d]>

EOF

4.创建数据库

groupadd mysql;useradd -M -g mysql mysql -s /sbin/nologin

chown -R mysql.mysql /usr/local/mysql /data/mysql

echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile

source /etc/profile

mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

5.启动mysqld服务

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

/etc/init.d/mysqld start

ss -tnl|grep 3306

LISTEN 0 80 :::3306 :::*

有以上信息出现证明本次安装完成

备注:设置systemctl方式启动,需要自己编制target文件并修改设置

cat >>/etc/systemd/system/mysqld.service<

[Unit]

Description=MySQL Server

Documentation=man:mysqld(8)

Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf

LimitNOFILE=5000

EOF

~]$ mysql

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.20 MySQL Community Server (GPL)

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值