centos 7系統下編譯安裝 mysql5.7教程_Mysql

來源:互聯網
上載者:User

一、安裝約定

     mysql安裝路徑: /usr/local/mysql

     mysql資料庫路徑: /data/mysql

     my設定檔路徑: /usr/local/mysql/my.cnf

二、卸載mariadb

# rpm -qa | grep mariadb# rpm -e --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64 包名是上一條查詢得知

三、建立使用者組、使用者

     添加mysql組 groupadd mysql

     添加使用者 useradd -g mysql mysql -s /bin/false

#下載源碼包

在官網如下地址下載最新版

      http://dev.mysql.com/downloads/mysql/5.7.html#downloads

      http://download.savannah.gnu.org/releases/libunwind/

      https://github.com/gperftools/gperftools/releases

# cd /usr/local/src/# wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz# wget http://gperftools.googlecode.com/files/gperftools-2.5.tar.gz# wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.x.tar.gz

libunwind安裝

# tar zxvf libunwind-1.1.tar.gz# cd libunwind-1.1# ./configure# make# make install

gperftools安裝

# cd ..# tar zxvf gperftools-2.1.tar.gz# cd gperftools-2.1# ./configure# make# make install# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf# ldconfig

mysql安裝

# cd ..# tar zxvf mysql-5.7.x.tar.gz# cd mysql-5.7.x

編譯前可用如下命令查看編譯參數說明

# cmake . -LH | more

如果中間過程有報錯,請刪除CMakeCache.txt,在重新編譯

rm -rf CMakeCache.txt

mysq編譯安裝

# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/data/mysql \ -DSYSCONFDIR=/etc \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_UNIX_ADDR=/dev/shm/mysql.sock \ -DMYSQL_TCP_PORT=3306 \ -DMYSQL_USER=mysql \ -DWITH_DEBUG=0 \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/usr/local/boost# make# make install ```  更改許可權 ```# chmod 755 /var/lib/mysql# cd /usr/local/mysql# chown -R mysql:mysql .

初始化mysql

/usr/local/mysql/bin/mysqld --initialize --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql --explicit_defaults_for_timestamp=1

建立mysql設定檔

# cp support-files/my-default.cnf /usr/local/mysql/my.cnf

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的協助,如果有疑問大家可以留言交流。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.