基于CentOS6.9的MariaDB二進制安裝

去mariadb官網(wǎng)下載二進制安裝包

進入官網(wǎng)www.mariadb.org選擇 Download

進入官網(wǎng)www.mariadb.org選擇 Download

點擊 Download

選擇版本

這里選擇5.5.57版本

*選擇需要安裝的二進制安裝包

選擇基于 x86平臺使用與Linux的編譯完的二進制包

謝謝MariaDB的免費軟件,開源精神是世界的...

最后這里是填寫相關(guān)信息的,這里我們無需填寫直接選擇下載


安裝環(huán)境

Linux 操作系統(tǒng) CentOS 6.9 版本

創(chuàng)建數(shù)據(jù)庫存放路徑和權(quán)限設(shè)置

創(chuàng)建存放數(shù)據(jù)庫目錄 -->創(chuàng)建系統(tǒng)用戶賬號 -->設(shè)置系統(tǒng)用戶對/app/data目錄的權(quán)限

[root@host-b app]#pwd
/app
[root@host-b app]#
[root@host-b app]#mkdir /app/data
[root@host-b app]#
[root@host-b app]#rz

[root@host-b app]#getent passwd mysql
[root@host-b app]#
[root@host-b app]#ls
data  mariadb-5.5.57-linux-x86_64.tar.gz
[root@host-b app]#
[root@host-b app]#useradd -r -d /app/data -s /sbin/nologin -u 36 mysql
[root@host-b app]#id mysql
uid=36(mysql) gid=36(mysql) groups=36(mysql)
[root@host-b app]#ll
total 218916
drwxr-xr-x. 2 root root      4096 Aug  2 12:33 data
-rw-r--r--. 1 root root 224162771 Aug  2  2017 mariadb-5.5.57-linux-x86_64.tar.gz
[root@host-b app]#
[root@host-b app]#chown mysql:mysql /app/data
[root@host-b app]#ll -d data
drwxr-xr-x. 2 mysql mysql 4096 Aug  2 12:33 data
[root@host-b app]#

解壓縮包

我們安裝的是人家已經(jīng)編譯好了的二進制程序包粘招,所以解壓后路徑不能隨便放拔第,按人家編譯好的環(huán)境來解壓!路徑為/usr/local

特別注意路徑要指定

[root@host-b app]#tar xvf mariadb-5.5.57-linux-x86_64.tar.gz -C /usr/local/  <--路徑一定要正確

修改二進制程序的名字和相關(guān)權(quán)限

因為我們安裝的是人家已經(jīng)編譯好的二進制程序包,人家編譯時規(guī)定名字叫mysql标沪,所以我們要修改名字朱沃,或者創(chuàng)建軟連接

修改解壓后目錄的名字 --> 創(chuàng)建軟鏈接

修改mysql目錄下的所有文件的所屬組為mysql

為了有權(quán)限執(zhí)行mysql目錄下的程序苞轿,修改mysql目錄下所有文件的所屬組為mysql

到這之后,我們的二進制程序已經(jīng)解壓完了逗物,雖然二進制程序有啦搬卒,但是還不能啟動。如果現(xiàn)在就啟動會報錯的翎卓,比如路徑錯誤等契邀,所以接下來我們還需要修改配置文件

修改配置文件

1. 我們先打開看一下系統(tǒng)自帶的配置文件

數(shù)據(jù)庫路徑與我們指定的/app/data不符合

2. 利用模板自己創(chuàng)建配置文件
選擇配置文件模板
切進存放模板的目錄選擇模板

創(chuàng)建一個配置文件目錄,把模板復(fù)制過去改名為 my.cfg

vim 編輯配給文件失暴,數(shù)據(jù)庫路徑是必須配置

生成對應(yīng)的mysql數(shù)據(jù)庫并放在 /app/data 目錄下

我們用一個腳本生成數(shù)據(jù)庫即可坯门,腳本在解壓縮目錄下的scripts目錄里 :
/mysql_install_db

把 /mysql_install_db 腳本找出來

執(zhí)行腳本 /mysql_install_db 生成數(shù)據(jù)庫

[root@host-b mysql]#pwd
/usr/local/mysql      <---執(zhí)行腳本的目錄
[root@host-b mysql]#scripts/mysql_install_db --datadir=/app/data --user=mysql  <--指定路徑和用戶
Installing MariaDB/MySQL system tables in '/app/data' ...
170804  4:14:58 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a fu
ture release.170804  4:14:58 [Note] ./bin/mysqld (mysqld 5.5.57-MariaDB) starting as process 4955 ...
OK
Filling help tables...
170804  4:14:59 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a fu
ture release.170804  4:14:59 [Note] ./bin/mysqld (mysqld 5.5.57-MariaDB) starting as process 4963 ...
OK

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 MariaDB root USER !
To do so, start the server, then issue the following commands:

'./bin/mysqladmin' -u root password 'new-password'
'./bin/mysqladmin' -u root -h host-b.6.9 password 'new-password'

Alternatively you can run:
'./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 MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='/app/data'

You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

[root@host-b mysql]#
[root@host-b mysql]#ll /app/data    <--查看該目錄
total 1084
-rw-rw----. 1 mysql mysql   16384 Aug  4 04:14 aria_log.00000001
-rw-rw----. 1 mysql mysql      52 Aug  4 04:14 aria_log_control
drwx------. 2 mysql root     4096 Aug  4 04:14 mysql               <--mysql數(shù)據(jù)庫
-rw-rw----. 1 mysql mysql   30346 Aug  4 04:14 mysql-bin.000001
-rw-rw----. 1 mysql mysql 1038814 Aug  4 04:14 mysql-bin.000002
-rw-rw----. 1 mysql mysql      38 Aug  4 04:14 mysql-bin.index
drwx------. 2 mysql mysql    4096 Aug  4 04:14 performance_schema
drwx------. 2 mysql root     4096 Aug  4 04:14 test
[root@host-b mysql]#
[root@host-b mysql]#

執(zhí)行完 /mysql_install_db 腳本后 /app/data 目錄下生成的數(shù)據(jù)庫文件

把服務(wù)腳本準備好,設(shè)置相關(guān)權(quán)限啟動服務(wù)

(1)把服務(wù)腳本 mysql.server 放到 /etc/inint.d/ 目錄下逗扒,并修改為 mysqld
(2)設(shè)置為開機啟動
(3)創(chuàng)建日志文件 mkdir /var/log/mysql.d 注意路徑
(4)修改日志文件的所屬主為 mysql
(5)service mysqld start 啟動服務(wù)

把二進制程序路徑添加到$PATH變量里

測試并設(shè)置口令

目前我們雖然能夠登陸數(shù)據(jù)庫但是不安全古戴,因為沒有設(shè)置安全口令誰都可以登錄;這樣不安全矩肩。

測試查看端都是否打開:

沒有設(shè)置安全口令之前:

執(zhí)行安全腳本mysql_secure_installation設(shè)置口令:


執(zhí)行安全腳本mysql_secure_installation的代碼塊:

[root@host-b bin]#mysql_secure_installation 
/usr/local/mysql/bin/mysql_secure_installation: line 393: find_mysql_client: command not
 found
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):      <-- 輸入當前root密碼,這里是回車
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y      <-- 設(shè)置root密碼么现恼? < y >
New password:                   <-- 這里輸入密碼
Re-enter new password:          <-- 再輸入一次密碼
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y          <-- 是否刪除匿名用戶? < y >
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n   <-- 是否禁止root遠程登錄?   < n > 
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n    <-- 是否刪除測試數(shù)據(jù)庫述暂? < y/n都可以 >
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y              <-- 現(xiàn)在從新加載權(quán)限表么痹升? < y >
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@host-b bin]#

設(shè)置安全口令之后:


結(jié)語

到這里就完成整個MariaDB數(shù)據(jù)庫的二進制安裝!自己學(xué)習用的畦韭,如果能夠幫到讀者是我的榮幸疼蛾;
最后還要感謝MariaDB數(shù)據(jù)庫的開發(fā)者們免費提供的軟件,開源精神是世界的艺配!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末察郁,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子转唉,更是在濱河造成了極大的恐慌皮钠,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,496評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件赠法,死亡現(xiàn)場離奇詭異麦轰,居然都是意外死亡,警方通過查閱死者的電腦和手機砖织,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,407評論 3 392
  • 文/潘曉璐 我一進店門款侵,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人侧纯,你說我怎么就攤上這事新锈。” “怎么了眶熬?”我有些...
    開封第一講書人閱讀 162,632評論 0 353
  • 文/不壞的土叔 我叫張陵妹笆,是天一觀的道長。 經(jīng)常有香客問我娜氏,道長拳缠,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,180評論 1 292
  • 正文 為了忘掉前任贸弥,我火速辦了婚禮窟坐,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘茂腥。我一直安慰自己狸涌,他們只是感情好,可當我...
    茶點故事閱讀 67,198評論 6 388
  • 文/花漫 我一把揭開白布最岗。 她就那樣靜靜地躺著帕胆,像睡著了一般。 火紅的嫁衣襯著肌膚如雪般渡。 梳的紋絲不亂的頭發(fā)上懒豹,一...
    開封第一講書人閱讀 51,165評論 1 299
  • 那天芙盘,我揣著相機與錄音,去河邊找鬼脸秽。 笑死儒老,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的记餐。 我是一名探鬼主播驮樊,決...
    沈念sama閱讀 40,052評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼片酝!你這毒婦竟也來了囚衔?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 38,910評論 0 274
  • 序言:老撾萬榮一對情侶失蹤雕沿,失蹤者是張志新(化名)和其女友劉穎练湿,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體审轮,經(jīng)...
    沈念sama閱讀 45,324評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡肥哎,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,542評論 2 332
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了疾渣。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片篡诽。...
    茶點故事閱讀 39,711評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖稳衬,靈堂內(nèi)的尸體忽然破棺而出霞捡,到底是詐尸還是另有隱情坐漏,我是刑警寧澤薄疚,帶...
    沈念sama閱讀 35,424評論 5 343
  • 正文 年R本政府宣布,位于F島的核電站赊琳,受9級特大地震影響街夭,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜躏筏,卻給世界環(huán)境...
    茶點故事閱讀 41,017評論 3 326
  • 文/蒙蒙 一板丽、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧趁尼,春花似錦埃碱、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,668評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至芝囤,卻和暖如春似炎,著一層夾襖步出監(jiān)牢的瞬間辛萍,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,823評論 1 269
  • 我被黑心中介騙來泰國打工羡藐, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留贩毕,地道東北人。 一個月前我還...
    沈念sama閱讀 47,722評論 2 368
  • 正文 我出身青樓仆嗦,卻偏偏與公主長得像辉阶,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子瘩扼,可洞房花燭夜當晚...
    茶點故事閱讀 44,611評論 2 353

推薦閱讀更多精彩內(nèi)容