mysql的編譯安裝

來源:互聯網
上載者:User

標籤:blank   mysql   target   title   

Mysql 一. Mysql的編譯安裝

1.安裝環境以及安裝包的準備

Mysql的安裝環境需要佔用很大的記憶體,所以把cpu核心數增添到了兩個,把記憶體至少加到2048以上

安裝包:

650) this.width=650;" title="wps18F5.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps18F5.tmp" src="http://s3.51cto.com/wyfs02/M00/87/6C/wKioL1ffkj-TuSFWAAAb_w23Evk333.jpg" "219" height="183" /> 安裝這個是為了編譯用

650) this.width=650;" title="wps18F6.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps18F6.tmp" src="http://s3.51cto.com/wyfs02/M02/87/6C/wKioL1ffkj-jvQJpAAAW_KSKUw0148.jpg" "223" height="162" />Mysql的安裝包

2.由於安轉前要擴大記憶體,所以要擴充容量,如果根分區的形式時LVM才可以擴容,這個也是之後安裝系統要注意的,盡量在安裝系統時就將根分區設定成為LVM,這樣才可以添加擴容,由於本次裝機時沒有採取該方式,所以只能重新添加一塊虛擬磁碟,將其設成LVM方式,將其掛載到原生一個目錄下。如最終結果:

650) this.width=650;" title="wps18F7.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps18F7.tmp" src="http://s3.51cto.com/wyfs02/M00/87/70/wKiom1ffkkChQ5ZSAABKJEFUdgE488.jpg" "225" height="244" />

650) this.width=650;" title="wps18F8.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps18F8.tmp" src="http://s3.51cto.com/wyfs02/M01/87/70/wKiom1ffkkGz2Zn-AAAT5jVGvNM604.jpg" "244" height="50" />

3.進到掛載目錄下,將安裝包移到掛載目錄下,解壓縮mysql包,安裝cmake 。

650) this.width=650;" title="wps18F9.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps18F9.tmp" src="http://s3.51cto.com/wyfs02/M00/87/6C/wKioL1ffkkKDl5bXAAAQP2cXduQ816.jpg" "244" height="47" />

4.切入mysql解壓縮目錄中,開始編譯安裝

Cmake

-DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1

-DWITH_INNOBASE_STORAGE_ENGINE=1

-DDEFAULT_CHARSET=utf8

-DDEFAULT_COLLATION=utf8_general_ci

-DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/

在cmake後會出現一些缺少依賴包,要注意把這些依賴封裝上,缺什麼,裝什麼。

650) this.width=650;" title="wps18FA.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps18FA.tmp" src="http://s3.51cto.com/wyfs02/M01/87/70/wKiom1ffkkaxOKcdAAA9b2AFM-k936.jpg" "244" height="156" />

yum install -y gcc-c++

yum install -y ncurses-devel

yum install -y bison

5.在修改後,重新編譯時間,要將之前的緩衝刪掉,然後重新編譯

rm -f CMakeCache.txt

二.Mysql初始化

1.建立立一個mysql使用者

650) this.width=650;" title="wps18FB.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps18FB.tmp" src="http://s3.51cto.com/wyfs02/M01/87/6C/wKioL1ffkkfBvy4PAAAaNfNaT9E240.jpg" "244" height="52" />

useradd -u 27 -d /usr/local/lnmp/mysql/ mysql

650) this.width=650;" title="wps18FC.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps18FC.tmp" src="http://s3.51cto.com/wyfs02/M00/87/70/wKiom1ffkkeiKpUWAAAPHX1Y84g722.jpg" "244" height="33" />

雖然這裡顯示的是有錯誤,但是cat /etc/passwd 還是可以看到有這個使用者

650) this.width=650;" title="wps18FD.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps18FD.tmp" src="http://s3.51cto.com/wyfs02/M02/87/6C/wKioL1ffkkjgkSIHAAAL4ZIzieU630.jpg" "244" height="23" />

建立使用者完畢

2.修改環境變數,使得mysql可以在任意路徑下開啟操作

650) this.width=650;" title="wps190E.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps190E.tmp" src="http://s3.51cto.com/wyfs02/M01/87/70/wKiom1ffkkjyDOBUAAAZoBkU6vM920.jpg" "244" height="60" />

650) this.width=650;" title="wps190F.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps190F.tmp" src="http://s3.51cto.com/wyfs02/M02/87/70/wKiom1ffkknhmoE8AAASYa_JZ2Y722.jpg" "244" height="58" />

Source使其生效,但是注意source和sh 的區別

3.複製mysql設定檔

650) this.width=650;" title="wps1910.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps1910.tmp" src="http://s3.51cto.com/wyfs02/M00/87/70/wKiom1ffkkrwdCljAAAkrtm1km0810.jpg" "244" height="85" />

4.修改mysql下檔案的所屬使用者和組

650) this.width=650;" title="wps1911.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps1911.tmp" src="http://s3.51cto.com/wyfs02/M00/87/70/wKiom1ffkkqCBMlUAAAs2OBLZ0w431.jpg" "244" height="118" />

5.初始化mysql

mysqld --user=mysql --initialize

650) this.width=650;" title="wps1912.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps1912.tmp" src="http://s3.51cto.com/wyfs02/M02/87/6C/wKioL1ffkk6TpQTIAAAzCG7eAFY417.jpg" "244" height="118" />

此時會給產生以一個暫時的密碼,之後還要重設:

hfq>o7*b>prQ

之後開啟mysql

650) this.width=650;" title="wps1913.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps1913.tmp" src="http://s3.51cto.com/wyfs02/M01/87/70/wKiom1ffkk-QiR5hAAALsD-szNM239.jpg" "244" height="29" />

6.再修改mysql下的檔案許可權

650) this.width=650;" title="wps1914.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps1914.tmp" src="http://s3.51cto.com/wyfs02/M00/87/6C/wKioL1ffkk_TBifmAAAowLoYq6Q500.jpg" "244" height="146" />

最後的結果是修改成這個樣子,注意data下的檔案所屬都是mysql

650) this.width=650;" title="wps1915.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps1915.tmp" src="http://s3.51cto.com/wyfs02/M00/87/70/wKiom1ffklDgaUU0AAAx27IkI-o136.jpg" "244" height="118" />

650) this.width=650;" title="wps1916.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps1916.tmp" src="http://s3.51cto.com/wyfs02/M02/87/6C/wKioL1ffklHjbpX5AAAxEbk148M072.jpg" "244" height="128" />

之後開啟mysqld

7.初始化修改密碼

mysql_secure_installation #按提示完成 mysql 安全設定,生產環境推薦使用

650) this.width=650;" title="wps1917.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; padding-right: 0px" border="0" alt="wps1917.tmp" src="http://s3.51cto.com/wyfs02/M01/87/70/wKiom1ffklKwdc-YAAAOcNzZwUw755.jpg" "244" height="29" />

設定的密碼最好是大小寫字母數字這些,之後一直回答的都是y

8.登陸mysql

650) this.width=650;" title="wps1927.tmp" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="wps1927.tmp" src="http://s3.51cto.com/wyfs02/M02/87/70/wKiom1ffklODWtS_AAAmo739IGw890.jpg" "244" height="167" />

mysql的編譯安裝

聯繫我們

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