欢迎光临
专业Linux运维二十年

CentOS 7.2 安装MariaDB详细过程

mariadb简介

mariadb数据库管理系统是mysql的一个分支,主要由开源社区在维护,采用gpl授权许可 mariadb的目的是完全兼容mysql,包括api和命令行,使之能轻松成为mysql的代替品。在存储引擎方面,使用xtradb(英语:xtradb)来代替mysql的innodb。 mariadb由mysql的创始人michael widenius(英语:michael widenius)主导开发,他早前曾以10亿美元的价格,将自己创建的公司mysql ab卖给了sun,此后,随着sun被甲骨文收购,mysql的所有权也落入oracle的手中。mariadb名称来自michael widenius的女儿maria的名字。
MariaDB 官网:https://mariadb.org/
MariaDB 下载:https://downloads.mariadb.org/
MariaDB Github地址:https://github.com/MariaDB/server

安装mariadb 5.5

安装mariadb 5.5是centos 7的默认版本,配置数据库服务器

?
1
2
3
4
5
6
7
8
[root@linuxprobe~]
# yum -y install mariadb-server
[root@linuxprobe~]
# vi /etc/my.cnf
# add follows within [mysqld] section
[mysqld]
character-
set
-server=utf8
[root@linuxprobe~]
# systemctl start mariadb
[root@linuxprobe~]
# systemctl enable mariadb
ln
-s
'/usr/lib/systemd/system/mariadb.service'
'/etc/systemd/system/multi-user.target.wants/mariadb.service'

初始化mariadb

复制代码 代码如下:
[root@linuxprobe~]# mysql_secure_installation   #和mysql一样,一路y

 

连接mariadb

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[root@linuxprobe ~]
# mysql -u root -p
enter password:
welcome to the mariadb monitor. commands end with ; or \g.
your mariadb connection
id
is 1023
server version: 5.5.50-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)]>
select
user,host,password from mysql.user;
+-----------+-----------+-------------------------------------------+
| user | host | password     |
+-----------+-----------+-------------------------------------------+
| root | localhost | *f1dae8bcdfca7a57f246e0f834ac35830a3d640e |
| root | 127.0.0.1 | *f1dae8bcdfca7a57f246e0f834ac35830a3d640e |
| root | ::1 | *f1dae8bcdfca7a57f246e0f834ac35830a3d640e |
+-----------+-----------+-------------------------------------------+
5 rows
in
set
(0.00 sec)
mariadb [(none)]> show databases;
+--------------------+
| database  |
+--------------------+
| information_schema |
| mysql  |
| performance_schema |
+--------------------+
5 rows
in
set
(0.05 sec)
mariadb [(none)]>
exit
;
bye

防火墙开启3306端口

?
1
2
3
4
5
# 客户端设置
[root@vdevops ~]
# firewall-cmd --add-service=mysql --permanent
success
[root@vdevops ~]
# firewall-cmd --reload
success

安装phpmyadmin

前提安装web服务器和php

安装phpmyadmin

?
1
2
3
4
5
6
7
8
# install from epel
[root@linuxprobe~]
# yum --enablerepo=epel -y install phpmyadmin php-mysql php-mcrypt
[root@linuxprobe~]
# vi /etc/httpd/conf.d/phpmyadmin.conf
# line 17: ip address you permit to access
require ip 127.0.0.1 10.1.1.0
/24
# line 34: ip address you permit to access
require ip 127.0.0.1 10.1.1.o
/24
[root@linuxprobe ~]
# systemctl restart httpd

使用web浏览器从客户端访问“http://(您的主机名或ip地址)/ phpmyadmin /’,然后在mariadb的用户在以下屏幕上登录。此示例使用root用户继续。

登录之后,您可以在这里操作mariadb

mariadb 主从复制

mariadb 主从复制和mysql主从复制相同

安装 mariadb 10.1

配置 centos sclo源仓库

复制代码 代码如下:
[root@linuxprobe ~]# yum –enablerepo=centos-sclo-rh -y install rh-mariadb101-mariadb-server

 

来自centos-sclo-rh的软件包安装在/ opt目录下。 要使用它,加载环境变量如下。

?
1
2
3
4
5
[root@linuxprobe ~]
# scl enable rh-mariadb101 bash
[root@linuxprobe ~]
# mysql -v
mysql ver 15.1 distrib 10.1.14-mariadb,
for
linux (x86_64) using editline wrapper
[root@linuxprobe ~]
# which mysql
/opt/rh/rh-mariadb101/root/usr/bin/mysql

如果您希望在登录时自动启用mariadb 10.1,请如下配置

?
1
2
3
4
5
[root@linuxprobe ~]
# vi /etc/profile.d/rh-mariadb101.sh
# create new
#!/bin/bash
source
/opt/rh/rh-mariadb101/enable
export
x_scls=
"`scl enable rh-mariadb101 'echo $x_scls'`"

启用mariadb 10.1并配置初始设置

复制代码 代码如下:
[root@linuxprobe ~]# mysql_secure_installation

 

脚本之家
赞(0) 打赏
未经允许不得转载:Linux老运维 » CentOS 7.2 安装MariaDB详细过程

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫