時(shí)間:2018.7.30
作者:李強(qiáng)
參考:man,info,magedu講義,萬(wàn)能的internet
實(shí)驗(yàn)環(huán)境:VMware? Workstation 12 Pro ,Centos 6.9,Centos 7.4,SecureCRT Version 8.1.4
聲明:以下英文純屬個(gè)人翻譯,英文B級(jí),歡迎糾正,以下內(nèi)容純屬個(gè)人理解,并沒有對(duì)錯(cuò),只是參考,盜版不糾,才能有限,希望不誤人子弟為好。
版本:v1-2018.7.30
1、https://www.cnblogs.com/BrightMoon/p/4730081.html
2、https://dev.mysql.com/doc/refman/5.6/en/installing.html
官方下載站點(diǎn):
https://dev.mysql.com/downloads/mysql/
可以下載rpm包,repo倉(cāng)庫(kù)。二進(jìn)制包等
一些鏡像站點(diǎn)如搜狐,阿里,網(wǎng)易等都不好使了。
mysql安裝為什么大部分使用二進(jìn)制安裝。而不是源碼手動(dòng)去編譯?
mysql使用的glibc進(jìn)行開發(fā)的。glibc庫(kù)是一個(gè)底層api,所以只要是linux,都會(huì)有g(shù)libc庫(kù)。所以,mysql安裝不需要考慮環(huán)境是否符合要求。移植性很方便。直接將編譯好的二進(jìn)制代碼復(fù)制到另外一個(gè)機(jī)器上,也是可以用的。
原理性東西:一般在linux下安裝一個(gè)軟件,不同軟件所需要的函數(shù)庫(kù)不同。于是會(huì)遇到一個(gè)現(xiàn)象:一個(gè)軟件復(fù)制到另外一個(gè)平臺(tái)可能無(wú)法運(yùn)行。安裝軟件需要先偵測(cè)環(huán)境就是出于此考慮。因?yàn)閙ysql使用的是通用的glibc函數(shù)庫(kù)。沒有對(duì)其他東西的依賴性。所以,從一個(gè)平臺(tái)復(fù)制到另外一個(gè)平臺(tái)能夠通用。并不需要去偵測(cè)環(huán)境。直接使用編譯好的二進(jìn)制即可
手動(dòng)編譯安裝,顯得步驟麻煩。基于mysql的特點(diǎn),二進(jìn)制安裝完全可以。
注:mysql5.5安裝的時(shí)候,需要用到cmake命令,所以需要保證你的機(jī)器上安裝了該命令。沒有的話,還要去安裝該cmake。也顯得麻煩。我暫時(shí)不想去安裝最新版本的了。
如果使用二進(jìn)制安裝升級(jí)怎么進(jìn)行?
升級(jí)獲取的還是二進(jìn)制壓縮包。那么,直接將指向目錄切換到新的目錄即可。
不需要涉及到像php一樣,手動(dòng)編譯可以達(dá)到自己定制模塊的好處。而mysql安裝的時(shí)候不需要涉及到模塊
mysql官方建議安裝方式:二進(jìn)制安裝。
以下為安裝二進(jìn)制版本5.6.41操作步驟
1、依賴庫(kù)檢查
主要是看二進(jìn)制安裝依賴的庫(kù)是否存在,數(shù)據(jù)庫(kù)初始化和服務(wù)啟動(dòng)需要此庫(kù)
shell> yum search libaio # search for info
shell> yum install libaio # install library
2、安裝相關(guān)規(guī)劃
軟件安裝目錄 /usr/loca/app/mysql_13306
數(shù)據(jù)庫(kù)存放目錄 /data/mysql_13306
port 13306
pid_file /data/mysql_13306/mysql_13306.pid
socket /data/mysql_13306/mysql_13306.socket
log_error /var/log/mysql_13306.log
1、創(chuàng)建用戶
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
2、下載二進(jìn)制包
shell> cd /usr/local/app
shell> wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz
shell> tar zxvf mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz
shell> mv mysql-5.6.41-linux-glibc2.12-x86_64 mysql_13306
shell> ln -s mysql_13306 ../mysql_13306
# 我覺得建立軟鏈接其實(shí)作用就是因?yàn)槟J(rèn)的路徑就是這里。當(dāng)我們安裝多實(shí)例的時(shí)候,這個(gè)步驟就沒有意義了。
shell>cd /usr/local/app/mysql_3306
shell> rm -rf data
shell> ln -s data /data/mysql_13306
3、為工作目錄指定用戶權(quán)限
shell> cd mysql_13306
shell> scripts/mysql_install_db --user=mysql #這里可以指定mysql安裝和安裝數(shù)據(jù)的位置。
# --basedir=path 使用mysqld程序的路徑 --datadir=path 數(shù)據(jù)庫(kù)安裝的路徑
#此腳本,默認(rèn)執(zhí)行的是
#./bin/mysqld --bootstrap --basedir=. --datadir=/var/lib/mysql --log
shell> chown -R root .
shell> chown -R mysql /data/mysql_13306
# 數(shù)據(jù)庫(kù)數(shù)據(jù)位置需要擁有mysql的權(quán)限。不能設(shè)置為root權(quán)限。否則無(wú)法啟動(dòng)。
shell> scripts/mysql_install_db --user=mysql --basedir=/usr/local/app/mysql_13306 --datadir=/usr/local/app/mysql_13306/data
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/home/ewifi/mysql/bin/mysqladmin -u root password 'new-password'
/home/ewifi/mysql/bin/mysqladmin -u root -h ewifi-yuhang password 'new-password'
Alternatively you can run:
/home/ewifi/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /home/ewifi/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /home/ewifi/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
/home/ewifi/mysql/bin/mysqld_safe --defaults-file=/home/ewifi/mysql/my.cnf &
4、修改配置文件指定mysql的安裝目錄和數(shù)據(jù)目錄
執(zhí)行完安裝數(shù)據(jù)庫(kù)腳本后,會(huì)在安裝路徑下自動(dòng)生成my.cnf配置文件。
主要設(shè)置參數(shù),在mysqld下配置。
[mysqld]
user =mysql //以mysql用戶權(quán)限運(yùn)行mysql服務(wù)
baseurl=/usr/loca/app/mysql_13306 //mysql二進(jìn)制程序路徑,默認(rèn)為當(dāng)前程序的./bin/mysqld
dataurl=/data/mysql_13306/ //mysql數(shù)據(jù)庫(kù)存放路徑, 默認(rèn)為/var/lib/mysql
因?yàn)槲覀兛赡芨鶕?jù)自己的數(shù)據(jù)安全,放在其他位置,可以將二進(jìn)制里的data目錄刪除,然后建立一個(gè)軟鏈接過去。然后設(shè)置data的屬性為mysl.mysql
port=13306
socket=/data/mysql_13306/mysql_13306.socket //socket文件,默認(rèn)路徑為/var/lib/mysql/mysql.sock
pid-file=/var/run/mysql_13306.pid //如果沒有指定,那么默認(rèn)為$datadir/`hostname`.pid
[mysqld_safe]
log-error=/var/log/mysql_13306.log
5、啟動(dòng)服務(wù)器
shell> bin/mysqld --user=mysql & # 或使用mysqld_safe
shell> bin/mysqld_safe --user=mysql --defaults-file=/usr/loca/app/mysql_13306/my.cnf & # 官方建議使用這個(gè)
#啟動(dòng)可以用mysqld也可以使用mysqld_safe,區(qū)別簡(jiǎn)單點(diǎn)就是mysqld_safe比mysql更安全,因?yàn)閙ysqld_safe啟動(dòng)后會(huì)監(jiān)控mysql服務(wù)狀態(tài)做到自動(dòng)重啟mysql服務(wù)的功能,本質(zhì)上用到的還是mysqld程序。
#如果安裝目錄和數(shù)據(jù)庫(kù)目錄改變,添加相關(guān)參數(shù)
6、添加啟動(dòng)腳本。
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql_13306.server
如果修改了baseurl和dataurl的位置,這里需要對(duì)這2個(gè)變量進(jìn)行賦值
這里調(diào)用的就是mysqld_safe
1、不同版本的安裝方式不一樣。需要參考官方安裝指導(dǎo)手冊(cè)
2、自定義的路徑,需要修改相關(guān)文件的相關(guān)變量。官方上是默認(rèn)路徑。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
分享文章:Mysql5.6版本二進(jìn)制安裝-創(chuàng)新互聯(lián)
文章位置:http://m.rwnh.cn/article40/iideo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、品牌網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)站維護(hù)、品牌網(wǎng)站設(shè)計(jì)、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容
移動(dòng)網(wǎng)站建設(shè)知識(shí)