CentOS 7 下 MariaDB 10. 安裝

系統(tǒng)

# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 

獲取包源

來自官網(wǎng)的包源 https://downloads.mariadb.org/mariadb/repositories/

# cd /etc/yum.repos.d
# cat >> MariaDB.repo <<EOF
# MariaDB 10.0 CentOS repository list - created 2016-03-29 03:06 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

安裝

安裝之前確保機器上面沒有YUM安裝的MySQL

# rpm -qa | grep -i mysql
or 
# yum remove $(rpm -qa | grep -i mysql )
# yum install MariaDB-server MariaDB-client

啟動

# systemctl start mysql.service
# systemctl enable mysql.service

設置root密碼

1.使用命令mysql_secure_installation

運行 mysql_secure_installation 設置root用戶密碼场斑、去除test數(shù)據(jù)庫虑稼、禁止root帳號遠程訪問等。推薦

# mysql_secure_installation

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): 
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
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
 ... 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] y
 ... Success!

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] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

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

Reload privilege tables now? [Y/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!

2.使用命令mysqladmin

# /usr/bin/mysqladmin -u root  -p'SOURCE-ROOT-PASSWORD' password 'GIVE-NEW-ROOT-PASSWORD'

測試下

# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 26
Server version: 10.0.24-MariaDB MariaDB Server

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

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

MariaDB [(none)]> quit
Bye

3.登陸到MariaDB console進行更改

[root@web01 tmp]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 10.0.24-MariaDB MariaDB Server

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

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

MariaDB [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> update user set password=PASSWORD("GIVE-NEW-ROOT-PASSWORD") where User='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> quit;
Bye

測試下

[root@web01 tmp]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 10.0.24-MariaDB MariaDB Server

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

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

MariaDB [(none)]> quit
Bye

選用合適的配置文件

MariaDB會給我們提供示例配置文件刑然,根據(jù)機器內(nèi)存進行選擇喇闸,稍作修改即可使用。

# ls /usr/share/mysql/my-*
/usr/share/mysql/my-huge.cnf             /usr/share/mysql/my-medium.cnf
/usr/share/mysql/my-innodb-heavy-4G.cnf  /usr/share/mysql/my-small.cnf
/usr/share/mysql/my-large.cnf
# cp  /usr/share/mysql/my-huge.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y

重載配置文件

# systemctl reload mysql.service

參考

最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市缩幸,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌竞思,老刑警劉巖表谊,帶你破解...
    沈念sama閱讀 217,826評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異盖喷,居然都是意外死亡爆办,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,968評論 3 395
  • 文/潘曉璐 我一進店門课梳,熙熙樓的掌柜王于貴愁眉苦臉地迎上來距辆,“玉大人余佃,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 164,234評論 0 354
  • 文/不壞的土叔 我叫張陵疟位,是天一觀的道長偏灿。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,562評論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮坏瘩,結果婚禮上,老公的妹妹穿的比我還像新娘漠魏。我一直安慰自己倔矾,他們只是感情好,可當我...
    茶點故事閱讀 67,611評論 6 392
  • 文/花漫 我一把揭開白布柱锹。 她就那樣靜靜地躺著哪自,像睡著了一般。 火紅的嫁衣襯著肌膚如雪禁熏。 梳的紋絲不亂的頭發(fā)上提陶,一...
    開封第一講書人閱讀 51,482評論 1 302
  • 那天,我揣著相機與錄音匹层,去河邊找鬼隙笆。 笑死,一個胖子當著我的面吹牛升筏,可吹牛的內(nèi)容都是我干的撑柔。 我是一名探鬼主播,決...
    沈念sama閱讀 40,271評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼您访,長吁一口氣:“原來是場噩夢啊……” “哼铅忿!你這毒婦竟也來了?” 一聲冷哼從身側響起灵汪,我...
    開封第一講書人閱讀 39,166評論 0 276
  • 序言:老撾萬榮一對情侶失蹤檀训,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后享言,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體峻凫,經(jīng)...
    沈念sama閱讀 45,608評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,814評論 3 336
  • 正文 我和宋清朗相戀三年览露,在試婚紗的時候發(fā)現(xiàn)自己被綠了荧琼。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,926評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖命锄,靈堂內(nèi)的尸體忽然破棺而出堰乔,到底是詐尸還是另有隱情,我是刑警寧澤脐恩,帶...
    沈念sama閱讀 35,644評論 5 346
  • 正文 年R本政府宣布镐侯,位于F島的核電站,受9級特大地震影響驶冒,放射性物質(zhì)發(fā)生泄漏苟翻。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,249評論 3 329
  • 文/蒙蒙 一只怎、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧怜俐,春花似錦身堡、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,866評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至季稳,卻和暖如春擅这,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背景鼠。 一陣腳步聲響...
    開封第一講書人閱讀 32,991評論 1 269
  • 我被黑心中介騙來泰國打工仲翎, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人铛漓。 一個月前我還...
    沈念sama閱讀 48,063評論 3 370
  • 正文 我出身青樓溯香,卻偏偏與公主長得像,于是被迫代替她去往敵國和親浓恶。 傳聞我的和親對象是個殘疾皇子玫坛,可洞房花燭夜當晚...
    茶點故事閱讀 44,871評論 2 354

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