lnmp-----mysql安裝----myql二進位安裝

來源:互聯網
上載者:User

標籤:data   mysql-5.5   程式   innodb   編譯php   l資料庫   root   軟體   oca   

mysql 二進位安裝,僅需要解壓就可以,不需要  cmake/configure,make,make install

 

[[email protected] tools]# pwd
/home/yang/tools

[[email protected] tools]# groupadd mysql
[[email protected] tools]# useradd -s /sbin/nologin -g mysql -M mysql

1.採用二進位方式安裝MySQL

[[email protected] tools]# tar -xf mysql-5.5.54-linux2.6-x86_64.tar.gz 

[[email protected] tools]# mv mysql-5.5.54-linux2.6-x86_64 /application/mysql-5.5.54   #移動並改名目錄

2.建立軟連結

[[email protected] tools]# ln -s /application/mysql-5.5.54/ /application/mysql  #設定軟串連

[[email protected] tools]# ls -l /application/      #查看mysql軟連結
total 8 
lrwxrwxrwx. 1 root root 26 Mar 2 11:58 mysql -> /application/mysql-5.5.54/
drwxr-xr-x. 13 root root 4096 Mar 2 11:53 mysql-5.5.54

當前lnmp一體化環境時候,mysql資料庫和nginx在一台伺服器上,如果mysql與nginx不在一台伺服器上時,nginx伺服器上的mysql資料庫軟體包只需要解壓移動到/application目錄,改名為mysql就可以,不要進行後面測初始化設定。

在非一體化的LNMP環境(及mysql與nginx不在一台伺服器上),編譯PHP環境時,也需要mysql資料庫環境,但是高版本的PHP,例如5.3版本以上,內建了PHP需要的mysql程式,因此,對於此類版本就不需要再nginx伺服器上安裝mysql軟體了,值需要再編譯PHP時指定相關的參數即可,這個PHP的編譯的參數為 --with-mysql=mysqlnd,標示PHP程式在編譯時間會調用內建的mysql的庫

3.初始化MySQL設定檔my.cnf

[[email protected] tools]# cd /application/mysql
[[email protected] mysql]# ls -l support-files/*.cnf
-rw-r--r--. 1 7161 31415 4691 Nov 29 00:10 support-files/my-huge.cnf
-rw-r--r--. 1 7161 31415 19759 Nov 29 00:10 support-files/my-innodb-heavy-4G.cnf
-rw-r--r--. 1 7161 31415 4665 Nov 29 00:10 support-files/my-large.cnf
-rw-r--r--. 1 7161 31415 4676 Nov 29 00:10 support-files/my-medium.cnf
-rw-r--r--. 1 7161 31415 2840 Nov 29 00:10 support-files/my-small.cnf

[[email protected] mysql]# /bin/cp support-files/my-small.cnf /etc/my.cnf  #因為是測試環境,所以選擇參數配置小的my-small.cnf配置模板,如果是生產環境可以根據硬體選擇更進階的設定檔

my-medium.cnf ==>my-small.cnf==>my-large.cnf==>my-huge.cnf==>my-innodb-heavy-4G.cnf   #對硬體的要求從低到高依次為

 

[[email protected] mysql]# yum install libaio
[[email protected] mysql]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql #初始化資料庫

[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld #拷貝MYSQL啟動指令碼到MySQL命令列

[[email protected] mysql]# sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe /etc/init.d/mysqld
[[email protected] mysql]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
[[email protected] mysql]# netstat -tulnp | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 9020/mysqld

 

設定MySQL開機自啟動

[[email protected] mysql]# chkconfig --add mysqld
[[email protected] mysql]# chkconfig mysqld on
[[email protected] mysql]# chkconfig --list mysqld
mysqld 0:off1:off2:on3:on4:on5:on6:off

lnmp-----mysql安裝----myql二進位安裝

聯繫我們

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