centos7.4 mysql 5.7.20 源碼安裝

來源:互聯網
上載者:User

標籤:debug   basedir   解壓   dir   evel   flush   mem   build   0.00   

1. 安裝依賴

yum install -y cmake bison bison-devel libaio-devel gcc gcc-c++ git  ncurses-devel

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20.tar.gz

wget https://zh.osdn.net/projects/sfnet_boost/downloads/boost/1.59.0/boost_1_59_0.tar.gz/


2. 解壓編譯安裝

[[email protected] ~]# tar xf mysql-5.7.20.tar.gz

[[email protected] ~]# mv boost_1_59_0.tar.gz mysql-5.7.20

[[email protected] ~]# cd mysql-5.7.20

[[email protected] mysql-5.7.20]# mkdir configure

[[email protected] mysql-5.7.20]# cd configure

[[email protected] configure]# cmake .. -DBUILD_CONFIG=mysql_release \

-DINSTALL_LAYOUT=STANDALONE \

-DCMAKE_BUILD_TYPE=RelWithDebInfo \

-DENABLE_DTRACE=OFF \

-DWITH_EMBEDDED_SERVER=OFF \

-DWITH_INNODB_MEMCACHED=ON \

-DWITH_SSL=bundled \

-DWITH_ZLIB=system \

-DWITH_PAM=ON \

-DCMAKE_INSTALL_PREFIX=/var/mysql/ \

-DINSTALL_PLUGINDIR="/var/mysql/lib/plugin" \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_EDITLINE=bundled \

-DFEATURE_SET=community \

-DCOMPILATION_COMMENT="MySQL Server (GPL)" \

-DWITH_DEBUG=OFF \

-DWITH_BOOST=..

[[email protected] configure]# make

[[email protected] configure]# make install                   # 此步驟很慢


3. 建立設定檔目錄及使用者

[[email protected] ~]# useradd -s /sbin/nologin mysql

[[email protected] ~]# mkdir -p /data/mysql

[[email protected] ~]# mkdir -p /var/mysql/log

[[email protected] ~]# chown -R mysql:mysql /data/mysql/

[[email protected] ~]# chown -R mysql:mysql /var/mysql/log


4. 修改設定檔

[[email protected] ~]# vim /etc/my.cnf

...

[mysqld]

datadir=/data/mysql

socket=/var/lib/mysql/mysql.sock

log_error=/var/mysql/log/error.log

basedir=/var/mysql


5. 初始化

[[email protected] ~]# /var/mysql/bin/mysqld --initialize --user=mysql

[[email protected] ~]# ll /data/mysql/

total 110628

-rw-r-----. 1 mysql mysql       56 Jul 10 17:51 auto.cnf

-rw-r-----. 1 mysql mysql      419 Jul 10 17:51 ib_buffer_pool

-rw-r-----. 1 mysql mysql 12582912 Jul 10 17:51 ibdata1

-rw-r-----. 1 mysql mysql 50331648 Jul 10 17:51 ib_logfile0

-rw-r-----. 1 mysql mysql 50331648 Jul 10 17:51 ib_logfile1

drwxr-x---. 2 mysql mysql     4096 Jul 10 17:51 mysql

drwxr-x---. 2 mysql mysql     8192 Jul 10 17:51 performance_schema

drwxr-x---. 2 mysql mysql     8192 Jul 10 17:51 sys

[[email protected] ~]# ll /var/mysql/log/

total 4

-rw-r-----. 1 mysql mysql 802 Jul 10 17:51 error.log



6. 修改設定檔

[[email protected] ~]# cp /var/mysql/support-files/mysql.server /etc/init.d/mysqld

[[email protected] ~]# vim /etc/init.d/mysqld    #找到如下兩行

...

basedir=/var/mysql/

datadir=/data/mysql

...

[[email protected] ~]# mkdir -p /var/lib/mysql

[[email protected] ~]# chown -R mysql:mysql /var/lib/mysql


7. 添加環境變數

[[email protected] mysql]# vim /etc/profile

...

MYSQL_HOME=/var/mysql/bin/

PATH=$PATH:$MYSQL_HOME

[[email protected] ~]# source /etc/profile


8 . 修改原始密碼

[[email protected] ~]# cat /var/mysql/log/error.log | grep generated

2018-07-10T09:51:31.365809Z 1 [Note] A temporary password is generated for [email protected]: pS:SCG1goPhj

[[email protected] ~]# /etc/init.d/mysqld start

[[email protected] ~]# ln -s /var/lib/mysql/mysql.sock /tmp/

[[email protected] ~]# mysql -uroot -p

密碼為: pS:SCG1goPhj

mysql> alter user 'root'@'localhost' identified by '123123';

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)


centos7.4 mysql 5.7.20 源碼安裝

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.