環境:已安裝好系統版本CentOS7.4,虛擬機內存4G+8核i7 CPU
1.安裝準備
源碼包下載以及解壓:html
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目錄mysql
yum install bison cmake libaio-devel ncurses-devel -y mkdir /data/mysql -p
2.編譯安裝mysqlsql
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.建立配置文件socket
cat >>/etc/mysql.cnf<<-EOF [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.建立數據庫ide
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服務ui
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<<-EOF [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>