標籤:資料庫 資料 mysql liunx centos
在官網擷取mariaDB的安裝包通xftp放到根目錄下
2.展開MariaDB檔案
tar xf mariadb-5.5.42-linux-x86_64.tar.gz -C /usr/local
3.協助文檔位置
/usr/local/mariadb-5.5.42-linux-x86_64/INSTALL-BINARY
4.為資料庫資料準備硬碟
fdisk /dev/sdb
pvcreate /dev/sdb1
vgcreate mysqlvg /dev/sdb1
lvcreate -l 1278 -n mydata mysqlvg
mke2fs -t ext4 -L MYDATA -b 4096 -m 3 /dev/mysqlvg/mydata
mkdir /mydata
vim /etc/fstab
mount -a
5.添加mysql組和使用者
# groupadd -r mysql
# useradd -g mysql -r mysql
# id mysql
uid=498(mysql) gid=498(mysql) groups=498(mysql)
6.更改/mydata/data的屬主屬組
# chown -R mysql.mysql /mydata/data
7.為mysql檔案夾做軟連結
# ln -sv mariadb-5.5.42-linux-x86_64 mysql
8.為mysql檔案夾內的所有檔案更改屬主屬組許可權
# chown -R root.mysql ./*
9.複製設定檔
mysql檔案下support中的my-*.cnf是mysql的設定檔範本,根據不通的記憶體大小選擇不通的模板
650) this.width=650;" title="6d134d00-b88e-475a-8db7-30cc7ca455a1" style="border-right-width:0px;border-bottom-width:0px;border-top-width:0px;" border="0" alt="6d134d00-b88e-475a-8db7-30cc7ca455a1" src="http://s3.51cto.com/wyfs02/M00/59/F6/wKiom1TxLbygVwhfAADWapEu0ZY455.jpg" width="696" height="85" />
因為系統安裝時預設安裝mysql的庫,所以會有mysql的設定檔.建議建立一個檔案夾把模板放到裡邊.
# mkdir /etc/mysql # cp support-files/my-large.cnf /etc/mysql/my.cnf # vim /etc/mysql/my.cnf
在設定檔中填加資料檔案目錄
650) this.width=650;" title="580e4efb-43b2-43df-8749-323838f0133d" style="border-right-width:0px;border-bottom-width:0px;border-top-width:0px;" border="0" alt="580e4efb-43b2-43df-8749-323838f0133d" src="http://s3.51cto.com/wyfs02/M00/59/F2/wKioL1TxLsqQHAFdAAGSYaOisa4012.jpg" width="624" height="325" />
10.初始化資料庫
# cd /usr/local/mysql/scripts
# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
mysql資料庫初始化完成,可以看到mysql的資料檔案在指定位置產生了.mysql服務查出設定檔是依次尋找多個不同位置,會合并多個不同檔案的參數並以最後找到的設定檔為準.所以這裡mysql使用的設定檔是/etc/mysql/my.cnf而不是/etc/my.cnf.
650) this.width=650;" title="96f4c5c3-1b9d-44d7-9229-39d215f4b804" style="border-right-width:0px;border-bottom-width:0px;border-top-width:0px;" border="0" alt="96f4c5c3-1b9d-44d7-9229-39d215f4b804" src="http://s3.51cto.com/wyfs02/M01/59/F6/wKiom1TxLbyT6-LkAACYUVhZKu0279.jpg" width="687" height="62" />
11.複製服務指令碼
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
650) this.width=650;" title="64185a30-3c9e-4e2c-b619-225858426d75" style="border-right-width:0px;border-bottom-width:0px;border-top-width:0px;" border="0" alt="64185a30-3c9e-4e2c-b619-225858426d75" src="http://s3.51cto.com/wyfs02/M02/59/F6/wKiom1TxLbyzFJEkAAB3OXXW3FM683.jpg" width="636" height="46" />
把mysqld服務加到服務列表
# chkconfig --add mysqld
650) this.width=650;" title="94aa08b1-e680-40bd-ac1f-696f3b8b5a39" style="border-right-width:0px;border-bottom-width:0px;border-top-width:0px;" border="0" alt="94aa08b1-e680-40bd-ac1f-696f3b8b5a39" src="http://s3.51cto.com/wyfs02/M00/59/F6/wKiom1TxLbyDW_ciAABe4ASsOkM530.jpg" width="635" height="45" />
12.啟動服務
可以看到mysql啟動成功,3306連接埠也已經監聽
650) this.width=650;" title="c41ec895-d12d-43e2-8d91-9913b80bee89" style="border-right-width:0px;border-bottom-width:0px;border-top-width:0px;width:700px;height:223px;" border="0" alt="c41ec895-d12d-43e2-8d91-9913b80bee89" src="http://s3.51cto.com/wyfs02/M01/59/F2/wKioL1TxLsrSbQgAAAHi2Ob0zq8920.jpg" width="700" height="223" hspace="0" vspace="0" />
13.把mysql指令碼添加到PATH路徑
# vim /etc/profile.d/mysql.sh
650) this.width=650;" title="ddcdbe81-296e-4549-ab0e-e5a13500f3af" style="border-right-width:0px;border-bottom-width:0px;border-top-width:0px;" border="0" alt="ddcdbe81-296e-4549-ab0e-e5a13500f3af" src="http://s3.51cto.com/wyfs02/M02/59/F2/wKioL1TxLsuBCZaaAAA22tAL-ME508.jpg" width="370" height="46" />
source一下mysql.sh檔案後,發現使用mysql命令可以串連到MariaDB版本為5.5.42
650) this.width=650;" title="45551979-97d3-4bb9-86d9-a5e05ba09b48" style="border-right-width:0px;border-bottom-width:0px;border-top-width:0px;width:700px;height:202px;" border="0" alt="45551979-97d3-4bb9-86d9-a5e05ba09b48" src="http://s3.51cto.com/wyfs02/M00/59/F2/wKioL1TxLsvz-576AAGHiANcTDQ917.jpg" width="700" height="202" hspace="0" vspace="0" />
本文出自 “bran” 部落格,請務必保留此出處http://branguo.blog.51cto.com/9768383/1615881
在centos6.5安裝MariaDB(mysql)