Linux安装MariaDB 5.5大全

7990阅读 1评论2014-08-28 luciafq
分类:Mysql/postgreSQL

Linux安装MariaDB 5.5大全

一、MariaDB介绍

MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。

MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。在存储引擎方面,使用XtraDB(英语:XtraDB)来代替MySQLInnoDB

MariaDBMySQL的创始人Michael WideniusDavid AxmarkAllan Larsso主导开发,他早前曾以10亿美元的价格,将自己创建的公司MySQL AB卖给了SUN,此后,随着SUN被甲骨文收购,MySQL的所有权也落入Oracle的手中。MariaDB目前是最佳的MySQL替代方案。

当前MariaDB的版本有几个系列,针对MySQL 5.5的是MariaDB 5.5,最新版本为5.5.39版。下面以这个版本讲述MariaDB在各种Linux发行版的安装。

 

二、使用MariaDB的公司或组织

那么哪些公司或组织在使用MariaDB呢?有:

Mozilla Corporation

Wikipedia

OpenSuse

Fedora

OLX

Nimbuzz

SlashGear

ArchLinux

Redhat Enterprise Linux (from RHEL7)

Slackware

Mageia

Slackware

TurboLinux

The Chakra Project

Gentoo

GNU/Linux KDu

 

三、MariaDB在各个Linux发行版的安装

MariaDB官方推荐使用各种包管理器通过软件仓库进行安装。

编辑/etc/yum.repos.d/MariaDB.repo文件,输入下面的内容:

1、把MariaDB添加到YUM仓库

目前MariaDB已经在RedHat 6RedHat 5CentOS 6CentOS 5Fedora 20191817OpenSUSE等系统的软件仓库内。所以,请按如下内容正确配置软件仓库。

 

RedHat 6 32

# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:29 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

RedHat 6 64

# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:30 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

RedHat 5 32

# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:31 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

RedHat 5 64

# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:31 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

CentOS 6 32

# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:21 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

CentOS 6 64

# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:22 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

CentOS 5 32

# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:23 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

CentOS 5 64

# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:23 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

Fedora 20 32

# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:34 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

Fedora 20 64

# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:35 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

Fedora 19 32

# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:31 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

Fedora 19 64

# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:34 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

Fedora 18 32

# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:32 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

Fedora 18 64

# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:33 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

Fedora 17 32

# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:33 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

Fedora 17 64

# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:33 UTC

#

[mariadb]

name = MariaDB

baseurl =

gpgkey=

gpgcheck=1

 

注意:把MariaDB.repo配置文件放入/etc/yum.repos.d/目录下。然后可以开始执行YUM命令了。

 

2、执行YUM安装MariaDB

RedHat 56以及Fedora 171819版本

# yum -y install MariaDB MariaDB-server

 

Fedora 20

# yum -y install mariadb mariadb-server

 

说明:如果MariaDBGPG签名密钥没有安装,YUM工具会在下载完所有包后自动安装它。

 

3OpenSUSE安装MariaDB

OpenSUSE 13安装MariaDB更特别,执行如下命令:

# zypper install mariadb

 

4、启动MariaDB

在安装完成后,执行下面的命令来启动MariaDB

RedHat 56CentOS 56以及Fedora 191817版本

# /etc/init.d/mysql start

 

Fedora 20OpenSUSE 13

# systemctl start mariadb.service

# systemctl enable mariadb.service

 

四、登录MariaDB

在终端Shell下输入mysql命令,默认情况下root用户的密码为空。

# mysql

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

Your MariaDB connection id is 1

Server version: 5.5.39-MariaDB MariaDB Server

 

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

 

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

 

MariaDB [(none)]>

View Existing Databases

Run the following command to view default databases that comes with installation.

MariaDB [(none)]> show databases;

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

| test               |

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

4 rows in set (0.00 sec)

 

输入quit命令退出MariaDBShell环境。

MariaDB [(none)]> quit

Bye

 

五、后续工作

在用root用户登录MariaDB后,最应该做的一件事是使用如下命令:

MariaDB [(none)]> set password=password(‘新密码’);

root用户设置密码。

 

1、重启MariaDB

RedHat 56CentOS 56以及Fedora 191817

# /etc/init.d/mysql restart

 

Fedora 20

# systemctl restart mariadb.service

 

2、设置MariaDB为开机自启动

# chkconfig mysql on

 

六、补充

1、在Debian 7 WheezyDebian 6 Squeeze安装MariaDB

$ sudo apt-get install python-software-properties

$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db

 

把下面的内容写入/etc/apt/sources.list配置文件

Debian 7 Wheezy

# MariaDB 5.5 repository list - created 2013-08-11 15:03 UTC

#

deb wheezy main

deb-src wheezy main

 

Debian 6 Squeeze

# MariaDB 5.5 repository list - created 2013-08-11 15:17 UTC

#

deb squeeze main

deb-src squeeze main

 

Ubuntu 13.10 Saucy

# MariaDB 5.5 repository list - created 2014-03-19 06:47 UTC

#

deb saucy main

deb-src saucy main

 

Ubuntu 12.04 Quantal

# MariaDB 5.5 repository list - created 2013-08-11 15:24 UTC

#

deb quantal main

deb-src quantal main

 

Ubuntu 12.04 Precise

# MariaDB 5.5 repository list - created 2013-08-11 15:24 UTC

#

deb precise main

deb-src precise main

 

再开始安装

$ sudo apt-get update

$ sudo apt-get install mariadb-server

七、总结

上面提到的技术都不难,难的是一一实验各种Linux系统,我用VMware虚拟了各种Linux系统,一一实验验证。从源码安装MariaDB常常会遇到很多坑,连官方都不建议从源码安装。所以针对不同的Linux系统,选择以上最适合的安装方式,MariaDB的安装就变成了一个非常轻松的工作。

上一篇:ClusterControl介绍
下一篇:读《深入分析Java Web技术内幕(修订版)》有感

文章评论