How To Install MariaDB on CentOS 7

From:?https://www.digitalocean.com/community/tutorials/how-to-install-mariadb-on-centos-7

Introduction

MariaDBis an open-source database management system, commonly installed as part of the popularLEMP(Linux, Nginx, MySQL/MariaDB, PHP/Python/Perl) stack. It uses a relational database and SQL (Structured Query Language) to manage its data. MariaDB is a fork of MySQL managed by the original MySQL developers. It's designed as a replacement for MySQL, uses some commands that referencemysql, and is the default package on CentOS 7.

In this tutorial, we will explain how to install the latest version of MariaDB on a CentOS 7 server. If you specifically need MySQL, see theHow to Install MySQL on CentOS 7guide. If you're wondering about MySQL vs. MariaDB, MariaDB is the preferred package and should work seamlessly in place of MySQL.

Prerequisites

To follow this tutorial, you will need:

A CentOS 7 with a non-root user withsudoprivileges. You can learn more about how to set up a user with these privileges in theInitial Server Setup with CentOS 7guide.

Step 1 — Installing MariaDB

We'll use Yum to install the MariaDB package, pressingywhen prompted to confirm that we wish to proceed:

sudo yum install mariadb-server

Once the installation is complete, we'll start the daemon with the following command:

sudo systemctl start mariadb

systemctldoesn't display the outcome of all service management commands, so to be sure we succeeded, we'll use the following command:

sudo systemctl status mariadb

If MariaDB has successfully started, the output should contain "Active: active (running)` and the final line should look something like:

Dec 01 19:06:20 centos-512mb-sfo2-01 systemd[1]: Started MariaDB database server.

Next, let's take a moment to ensure that MariaDB starts at boot, using thesystemctl enablecommand, which will create the necessary symlinks.

sudo systemctl enable mariadb

Output

Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

Next, we'll turn our attention to securing our installation.

Step 3 — Securing the MariaDB Server

MariaDB includes a security script to change some of the less secure default options for things like remote root logins and sample users. Use this command to run the security script:

sudo mysql_secure_installation

The script provides a detailed explanation for every step. The first prompts asks for the root password, which hasn't been set so we'll pressENTERas it recommends. Next, we'll be prompted to set that root password, which we'll do.

Then, we'll accept all the security suggestions by pressingYand thenENTERfor the remaining prompts, which will remove anonymous users, disallow remote root login, remove the test database, and reload the privilege tables.

Finally, now that we've secured the installation, we'll verify it's working.

Step 4 — Testing the Installation

We can verify our installation and get information about it by connecting with themysqladmintool, a client that lets you run administrative commands. Use the following command to connect to MariaDB asroot(-u root), prompt for a password (-p), and return the version.

mysqladmin -u root -p version

You should see output similar to this:

Output

mysqladmin? Ver 9.0 Distrib 5.5.50-MariaDB, for Linux on x86_64

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Server version? ? ? ? ? 5.5.50-MariaDB

Protocol version? ? ? ? 10

Connection? ? ? ? ? ? ? Localhost via UNIX socket

UNIX socket? ? ? ? ? ? /var/lib/mysql/mysql.sock

Uptime:? ? ? ? ? ? ? ? 4 min 4 sec

Threads: 1? Questions: 42? Slow queries: 0? Opens: 1? Flush tables: 2? Open tables: 27? Queries per second avg: 0.172

This indicates the installation has been successful.

Conclusion

In this tutorial, we've installed and secured MariaDB on a CentOS 7 server. To learn more about using MariaDB, this guide tolearning more about MySQL commandscan help. You might also considerimplementing some additional security measures.



Other


allow remote connection

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

FLUSH PRIVILEGES;

sudo firewall-cmd --permanent --add-port=3306/tcp

sudo firewall-cmd --reload

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市亩歹,隨后出現(xiàn)的幾起案子抱完,更是在濱河造成了極大的恐慌,老刑警劉巖酱固,帶你破解...
    沈念sama閱讀 212,816評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡杜顺,警方通過查閱死者的電腦和手機裁僧,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,729評論 3 385
  • 文/潘曉璐 我一進店門个束,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人聊疲,你說我怎么就攤上這事茬底。” “怎么了获洲?”我有些...
    開封第一講書人閱讀 158,300評論 0 348
  • 文/不壞的土叔 我叫張陵阱表,是天一觀的道長。 經(jīng)常有香客問我贡珊,道長最爬,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,780評論 1 285
  • 正文 為了忘掉前任门岔,我火速辦了婚禮爱致,結果婚禮上,老公的妹妹穿的比我還像新娘固歪。我一直安慰自己蒜鸡,他們只是感情好,可當我...
    茶點故事閱讀 65,890評論 6 385
  • 文/花漫 我一把揭開白布牢裳。 她就那樣靜靜地躺著逢防,像睡著了一般。 火紅的嫁衣襯著肌膚如雪蒲讯。 梳的紋絲不亂的頭發(fā)上忘朝,一...
    開封第一講書人閱讀 50,084評論 1 291
  • 那天,我揣著相機與錄音判帮,去河邊找鬼局嘁。 笑死,一個胖子當著我的面吹牛晦墙,可吹牛的內容都是我干的悦昵。 我是一名探鬼主播,決...
    沈念sama閱讀 39,151評論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼晌畅,長吁一口氣:“原來是場噩夢啊……” “哼但指!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 37,912評論 0 268
  • 序言:老撾萬榮一對情侶失蹤棋凳,失蹤者是張志新(化名)和其女友劉穎拦坠,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體剩岳,經(jīng)...
    沈念sama閱讀 44,355評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡贞滨,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 36,666評論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了拍棕。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片晓铆。...
    茶點故事閱讀 38,809評論 1 341
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖莫湘,靈堂內的尸體忽然破棺而出尤蒿,到底是詐尸還是另有隱情郑气,我是刑警寧澤幅垮,帶...
    沈念sama閱讀 34,504評論 4 334
  • 正文 年R本政府宣布,位于F島的核電站尾组,受9級特大地震影響忙芒,放射性物質發(fā)生泄漏。R本人自食惡果不足惜讳侨,卻給世界環(huán)境...
    茶點故事閱讀 40,150評論 3 317
  • 文/蒙蒙 一呵萨、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧跨跨,春花似錦潮峦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,882評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至耕渴,卻和暖如春拘悦,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背橱脸。 一陣腳步聲響...
    開封第一講書人閱讀 32,121評論 1 267
  • 我被黑心中介騙來泰國打工础米, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人添诉。 一個月前我還...
    沈念sama閱讀 46,628評論 2 362
  • 正文 我出身青樓屁桑,卻偏偏與公主長得像,于是被迫代替她去往敵國和親栏赴。 傳聞我的和親對象是個殘疾皇子蘑斧,可洞房花燭夜當晚...
    茶點故事閱讀 43,724評論 2 351

推薦閱讀更多精彩內容