mariadb安裝

1、安裝MariaDB

安裝命令

yum -y install mariadb mariadb-server

安裝完成MariaDB,首先啟動MariaDB

systemctl start mariadb

設置開機啟動

systemctl enable mariadb

接下來進行MariaDB的相關簡單配置

mysql_secure_installation

首先是設置密碼,會提示先輸入密碼

Enter current password for root (enter for none):<–初次運行直接回車

設置密碼

Set root password? [Y/n]?<– 是否設置root用戶密碼,輸入y并回車或直接回車

New password:<– 設置root用戶的密碼

Re-enter new password:?<– 再輸入一次你設置的密碼

其他配置

Remove anonymous users? [Y/n]?<– 是否刪除匿名用戶,回車

Disallow root login remotely? [Y/n]?<–是否禁止root遠程登錄,回車,

Remove test database and access to it? [Y/n]?<– 是否刪除test數據庫,回車

Reload privilege tables now? [Y/n]?<– 是否重新加載權限表,回車

初始化MariaDB完成,接下來測試登錄

mysql -uroot -ppassword

完成。


[root@localhost ~]# rpm -qa | grep mysql

[root@localhost ~]# rpm -qa | grep mariadb

mariadb-libs-5.5.56-2.el7.x86_64

[root@localhost ~]# find / -name mariadb-libs-5.5.56-2.el7.x86_64

find: ‘/run/user/1000/gvfs’: 權限不夠

[root@localhost ~]# find . -name mariadb-libs-5.5.56-2.el7.x86_64

[root@localhost ~]#?

[root@localhost ~]# yum -y install mariadb mariadb-server

已加載插件:fastestmirror, langpacks

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was

12: Timeout on http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')

base | 3.6 kB 00:00:00?

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was

12: Timeout on http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')

extras | 3.4 kB 00:00:00?

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was

12: Timeout on http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')

updates | 3.4 kB 00:00:00?

Loading mirror speeds from cached hostfile

* base: mirrors.aliyun.com

* extras: mirrors.aliyun.com

* updates: mirrors.aliyun.com

正在解決依賴關系

--> 正在檢查事務

---> 軟件包 mariadb.x86_64.1.5.5.56-2.el7 將被 安裝

---> 軟件包 mariadb-server.x86_64.1.5.5.56-2.el7 將被 安裝

--> 正在處理依賴關系 perl-DBI,它被軟件包 1:mariadb-server-5.5.56-2.el7.x86_64 需要

--> 正在處理依賴關系 perl-DBD-MySQL,它被軟件包 1:mariadb-server-5.5.56-2.el7.x86_64 需要

--> 正在處理依賴關系 perl(Data::Dumper),它被軟件包 1:mariadb-server-5.5.56-2.el7.x86_64 需要

--> 正在處理依賴關系 perl(DBI),它被軟件包 1:mariadb-server-5.5.56-2.el7.x86_64 需要

--> 正在檢查事務

---> 軟件包 perl-DBD-MySQL.x86_64.0.4.023-5.el7 將被 安裝

---> 軟件包 perl-DBI.x86_64.0.1.627-4.el7 將被 安裝

--> 正在處理依賴關系 perl(RPC::PlServer) >= 0.2001,它被軟件包 perl-DBI-1.627-4.el7.x86_64 需要

--> 正在處理依賴關系 perl(RPC::PlClient) >= 0.2000,它被軟件包 perl-DBI-1.627-4.el7.x86_64 需要

---> 軟件包 perl-Data-Dumper.x86_64.0.2.145-3.el7 將被 安裝

--> 正在檢查事務

---> 軟件包 perl-PlRPC.noarch.0.0.2020-14.el7 將被 安裝

--> 正在處理依賴關系 perl(Net::Daemon) >= 0.13,它被軟件包 perl-PlRPC-0.2020-14.el7.noarch 需要

--> 正在處理依賴關系 perl(Net::Daemon::Test),它被軟件包 perl-PlRPC-0.2020-14.el7.noarch 需要

--> 正在處理依賴關系 perl(Net::Daemon::Log),它被軟件包 perl-PlRPC-0.2020-14.el7.noarch 需要

--> 正在處理依賴關系 perl(Compress::Zlib),它被軟件包 perl-PlRPC-0.2020-14.el7.noarch 需要

--> 正在檢查事務

---> 軟件包 perl-IO-Compress.noarch.0.2.061-2.el7 將被 安裝

--> 正在處理依賴關系 perl(Compress::Raw::Zlib) >= 2.061,它被軟件包 perl-IO-Compress-2.061-2.el7.noarch 需要

--> 正在處理依賴關系 perl(Compress::Raw::Bzip2) >= 2.061,它被軟件包 perl-IO-Compress-2.061-2.el7.noarch 需要

---> 軟件包 perl-Net-Daemon.noarch.0.0.48-5.el7 將被 安裝

--> 正在檢查事務

---> 軟件包 perl-Compress-Raw-Bzip2.x86_64.0.2.061-3.el7 將被 安裝

---> 軟件包 perl-Compress-Raw-Zlib.x86_64.1.2.061-4.el7 將被 安裝

--> 解決依賴關系完成

依賴關系解決

========================================================================================

Package 架構 版本 源 大小

========================================================================================

正在安裝:

mariadb x86_64 1:5.5.56-2.el7 base 8.7 M

mariadb-server x86_64 1:5.5.56-2.el7 base 11 M

為依賴而安裝:

perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k

perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k

perl-DBD-MySQL x86_64 4.023-5.el7 base 140 k

perl-DBI x86_64 1.627-4.el7 base 802 k

perl-Data-Dumper x86_64 2.145-3.el7 base 47 k

perl-IO-Compress noarch 2.061-2.el7 base 260 k

perl-Net-Daemon noarch 0.48-5.el7 base 51 k

perl-PlRPC noarch 0.2020-14.el7 base 36 k

事務概要

========================================================================================

安裝 2 軟件包 (+8 依賴軟件包)

總下載量:21 M

安裝大小:110 M

Downloading packages:

警告:/var/cache/yum/x86_64/7/base/packages/mariadb-server-5.5.56-2.el7.x86_64.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID f4a80eb5: NOKEY

mariadb-server-5.5.56-2.el7.x86_64.rpm 的公鑰尚未安裝

(1/10): mariadb-server-5.5.56-2.el7.x86_64.rpm | 11 MB 00:00:02?

(2/10): mariadb-5.5.56-2.el7.x86_64.rpm | 8.7 MB 00:00:02?

(3/10): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm | 32 kB 00:00:00?

(4/10): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm | 57 kB 00:00:00?

(5/10): perl-DBD-MySQL-4.023-5.el7.x86_64.rpm | 140 kB 00:00:00?

(6/10): perl-Data-Dumper-2.145-3.el7.x86_64.rpm | 47 kB 00:00:00?

(7/10): perl-IO-Compress-2.061-2.el7.noarch.rpm | 260 kB 00:00:00?

(8/10): perl-Net-Daemon-0.48-5.el7.noarch.rpm | 51 kB 00:00:00?

(9/10): perl-PlRPC-0.2020-14.el7.noarch.rpm | 36 kB 00:00:00?

(10/10): perl-DBI-1.627-4.el7.x86_64.rpm | 802 kB 00:00:00?

----------------------------------------------------------------------------------------

總計 8.1 MB/s | 21 MB 00:02?

從 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 檢索密鑰

導入 GPG key 0xF4A80EB5:

用戶ID : "CentOS-7 Key (CentOS 7 Official Signing Key) "

指紋 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5

軟件包 : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)

來自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

正在安裝 : perl-Data-Dumper-2.145-3.el7.x86_64 1/10?

正在安裝 : 1:mariadb-5.5.56-2.el7.x86_64 2/10?

正在安裝 : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 3/10?

正在安裝 : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 4/10?

正在安裝 : perl-IO-Compress-2.061-2.el7.noarch 5/10?

正在安裝 : perl-Net-Daemon-0.48-5.el7.noarch 6/10?

正在安裝 : perl-PlRPC-0.2020-14.el7.noarch 7/10?

正在安裝 : perl-DBI-1.627-4.el7.x86_64 8/10?

正在安裝 : perl-DBD-MySQL-4.023-5.el7.x86_64 9/10?

正在安裝 : 1:mariadb-server-5.5.56-2.el7.x86_64 10/10?

驗證中 : perl-DBI-1.627-4.el7.x86_64 1/10?

驗證中 : perl-Net-Daemon-0.48-5.el7.noarch 2/10?

驗證中 : perl-Data-Dumper-2.145-3.el7.x86_64 3/10?

驗證中 : perl-PlRPC-0.2020-14.el7.noarch 4/10?

驗證中 : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 5/10?

驗證中 : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 6/10?

驗證中 : 1:mariadb-server-5.5.56-2.el7.x86_64 7/10?

驗證中 : perl-IO-Compress-2.061-2.el7.noarch 8/10?

驗證中 : perl-DBD-MySQL-4.023-5.el7.x86_64 9/10?

驗證中 : 1:mariadb-5.5.56-2.el7.x86_64 10/10

已安裝:

mariadb.x86_64 1:5.5.56-2.el7 mariadb-server.x86_64 1:5.5.56-2.el7

作為依賴被安裝:

perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7?

perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7?

perl-DBD-MySQL.x86_64 0:4.023-5.el7?

perl-DBI.x86_64 0:1.627-4.el7?

perl-Data-Dumper.x86_64 0:2.145-3.el7?

perl-IO-Compress.noarch 0:2.061-2.el7?

perl-Net-Daemon.noarch 0:0.48-5.el7?

perl-PlRPC.noarch 0:0.2020-14.el7

完畢!

[root@localhost ~]# systemctl start mariadb

[root@localhost ~]# systemctl enable maiadb

Failed to execute operation: No such file or directory

[root@localhost ~]# systemctl enable mariadb

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

[root@localhost ~]# 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]?

... 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]?

- 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]?

... 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@localhost ~]# mysql -u root -p

Enter password:?

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 10

Server version: 5.5.56-MariaDB MariaDB Server

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

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

MariaDB [(none)]>

2、配置MariaDB的字符集

文件/etc/my.cnf

vi /etc/my.cnf

在[mysqld]標簽下添加

init_connect='SET collation_connection = utf8_unicode_ci'

init_connect='SET NAMES utf8'

character-set-server=utf8

collation-server=utf8_unicode_ci

skip-character-set-client-handshake

文件/etc/my.cnf.d/client.cnf

vi /etc/my.cnf.d/client.cnf

在[client]中添加

default-character-set=utf8

文件/etc/my.cnf.d/mysql-clients.cnf

vi /etc/my.cnf.d/mysql-clients.cnf

在[mysql]中添加

default-character-set=utf8

?全部配置完成,重啟mariadb

systemctl restart mariadb

之后進入MariaDB查看字符集

[root@localhost ~]# mysql -u root -p

Enter password:?

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 14

Server version: 5.5.56-MariaDB MariaDB Server

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

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

MariaDB [(none)]> show variables like "%character%";show variables like "%collation%";

+--------------------------+----------------------------+

| Variable_name | Value |

+--------------------------+----------------------------+

| character_set_client | utf8 |

| character_set_connection | utf8 |

| character_set_database | latin1 |

| character_set_filesystem | binary |

| character_set_results | utf8 |

| character_set_server | latin1 |

| character_set_system | utf8 |

| character_sets_dir | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

8 rows in set (0.01 sec)

+----------------------+-------------------+

| Variable_name | Value |

+----------------------+-------------------+

| collation_connection | utf8_general_ci |

| collation_database | latin1_swedish_ci |

| collation_server | latin1_swedish_ci |

+----------------------+-------------------+

3 rows in set (0.00 sec)


轉自:https://www.cnblogs.com/zhanzhan/p/7729981.html

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,316評論 6 531
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 98,481評論 3 415
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 176,241評論 0 374
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 62,939評論 1 309
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 71,697評論 6 409
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,182評論 1 324
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,247評論 3 441
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,406評論 0 288
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 48,933評論 1 334
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 40,772評論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 42,973評論 1 369
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,516評論 5 359
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,209評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,638評論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,866評論 1 285
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,644評論 3 391
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 47,953評論 2 373

推薦閱讀更多精彩內容