LNMP環境部署----之Mysql安裝部署

Mysql安裝部署


1、安裝概覽

MySQL有幾種不同的產品線,且每種產品線又有很多不同的版本,這裏選擇當前企業使用最廣的社區版MySQL5.5系列作爲LNMP的組合環境數據庫平臺。

企業場景MySQL安裝方式一覽

序號

MySQL安裝方式

特點說明

1

yum/rpm包安裝

特點是簡單,但是沒法定製安裝,入門新手常用這種方式。

2

二進制安裝

解壓軟件簡單配置後就可以使用,不用安裝,速度較快,專業DBA喜歡這種方式,軟件名如:mysql-5.5.32-liux2.6-x86_64.tar.gz.  

3

源碼編譯安裝

特點是可以定製安裝參數,但安裝時間長,便  如:安符集安裝路徑,軟件名如:mysql-5.5.32.tar.gz

4

源碼軟件結合

把源碼軟件製作成符合要求的rpm,放到yum倉庫裏,然後通過yum來安裝。結合上面13的優點,即安裝快速,可任意定製參數,但是也需要具有備更深能力的人員才行。

安裝步驟介紹

1創建MySQL用戶的賬號

首先以root身份登錄到Linux系統中,然後執行如下命令創建mysql組用戶組賬號:

[root@web01 ~]# groupadd mysql

提示:MySQL5.5產品系列和早期的MySQl5.05.1系列屬於不同的產品線,因此,安裝方式有所不同。

創建mysql用戶

[root@web01 ~]# useradd -s /sbin/nologin -M mysql

創建存放安裝包的目錄

[root@web01 ~]# mkdir /home/oldboy/tools/ -p

[root@web01 ~]# cd /home/oldboy/tools/

[root@web01 ~]# mkdir /application/mysql/data/ -p

[root@web01 tools]# wget -q http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.53-linux2.6-x86_64.tar.gz

2、初始化

[root@web01 tools]# ls

mysql-5.5.53-linux2.6-x86_64.tar.gz  nginx-1.6.3 nginx-1.6.3.tar.gz

[root@web01 tools]# tar xf mysql-5.5.53-linux2.6-x86_64.tar.gz

[root@web01 tools]# ls

mysql-5.5.53-linux2.6-x86_64  xf mysql-5.5.53-linux2.6-x86_64.tar.gz  nginx-1.6.3 nginx-1.6.3.tar.gz

[root@web01 tools]# mv mysql-5.5.53-linux2.6-x86_64/ mysql-5.5.53

[root@web01 tools]# ls

mysql-5.5.53 mysql-5.5.53.tar.gz nginx-1.6.3  nginx-1.6.3.tar.gz

[root@web01 tools]# cd mysql-5.5.53

[root@web01 application]# ln -s/application/mysql-5.5.53/ /application/mysql

[root@web01 mysql]# ls -l /application/

總用量 8

lrwxrwxrwx  1root root   26 12月 11 15:56 mysql -> /application/mysql-5.5.53/

drwxr-xr-x 13 root root 4096 12月 11 15:46 mysql-5.5.53

lrwxrwxrwx  1root root   25 12月 11 10:47 nginx -> /application/nginx-1.6.3/

drwxr-xr-x 11 root root 4096 12月 11 10:53 nginx-1.6.3

[root@web01 mysql]# \cpsupport-files/my-small.cnf  /etc/my.cnf

[root@web01 mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data/

Installing MySQL system tables...

161211 16:10:40 [Note] Ignoring --secure-file-privvalue as server is running with --bootstrap.

161211 16:10:40 [Note]/application/mysql/bin/mysqld (mysqld 5.5.53) starting as process 11591 ...

OK

Filling help tables...

161211 16:10:40 [Note] Ignoring --secure-file-privvalue as server is running with --bootstrap.

161211 16:10:40 [Note]/application/mysql/bin/mysqld (mysqld 5.5.53) starting as process 11598 ...

OK

提示兩個OK,代表成功了。

3、配置及啓動Mysql數據庫

cd /application/mysql/

[root@web01 mysql]# ls -ld /tmp

drwxrwxrwt. 3 root root 4096 12月 11 17:32 /tmp

[root@web01 mysql]# chmod -R 1777 /tmp/

設置MySQL啓動腳本

[root@web01 mysql]#cpsupport-files/mysql.server  /etc/init.d/mysqld

[root@web01 mysql]# chmod +x /etc/init.d/mysqld

[root@web01 mysql]# sed -i's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe/etc/init.d/mysqld

[root@web01 mysql]# /etc/init.d/mysqld start

Starting MySQL.. SUCCESS!

查看MySQL服務有沒有啓動

[root@web01 mysql]# lsof -i :3306

COMMAND  PID  USER   FD  TYPE DEVICE SIZE/OFF NODE NAME

mysqld  11967mysql   10u  IPv4 33961      0t0  TCP *:mysql (LISTEN)

設置MySQL服務開機自啓動。

[root@web01 data]# chkconfig --add mysqld

[root@web01 data]# chkconfig  mysqld on

[root@web01 data]# chkconfig --list |grep mysqld

mysqld         0:off   1:off   2:on   3:on    4:on    5:on   6:off

配置mysql命令全局使用路徑

[root@web01 data]# echo 'exportPATH=/application/mysql/bin:PATH' >>/etc/profile

export PATH=/application/mysql/bin:PATH

[root@web01 data]# tail -1 /etc/profile

export PATH=/application/mysql/bin:PATH

[root@web01 data]# source /etc/profile

[root@web01 mysql]# echo $PATH

/application/mysql/bin:PATH

[root@web01 mysql]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.53 MySQL Community Server (GPL)

 

Copyright (c) 2000, 2016, Oracle and/or itsaffiliates. All rights reserved.

 

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarks of theirrespective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clearthe current input statement.

 

mysql>

由全局路徑配置不不導致的問題案例見文章:

http://oldboy.blog.51cto.com/2561410/1122867


謝謝恩師,老男孩老師的指導,以上自己做的總結。

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章