在RHEL / CentOS / Fedora和Debian / Ubuntu中安装MariaDB 5.5数据库

MariaDB的是二进制下拉更换为MySQL,MySQL项目的原始作者和具有更多的功能和更好的性能增强MySQL的完全兼容的发展。 直到我们写这篇文章,MariaDB的10.0系列是开发版本( 阿尔法 )和MariaDB的5.5是当前稳定(GA)发布。

在Linux中安装MariaDB

为什么要使用MariaDB?

正如我们都知道的MySQL被广泛使用和最流行的RDBMS和开发商的首选。 2008年 中,MySQLSun微系统 ,这后来被甲骨文收购并不再是开源的收购。

那么,MariaDB的是由蒙蒂计划AB&MariaDB 基金会赞助和独立由MySQL的核心开发人员和其他社区成员,真正的开源开发。 迈克尔蒙蒂维德纽斯大卫Axmark,Allan Larsso 的MySQL的创始人和蒙蒂计划AB创建MySQL数据库的人现在是落后MariaDB的 他们将监督MariaDB的发展基础。

谁在使用MariaDB?

有分布与大型网站的数量已经切换到MariaDB的 ,有的则是:

  1. Mozilla公司
  2. 维基百科
  3. OpenSuse
  4. Fedora
  5. OLX
  6. Nimbuzz
  7. SlashGear
  8. ArchLinux
  9. Redhat企业版Linux(从RHEL7)
  10. Slackware
  11. Mageia
  12. Slackware
  13. TurboLinux
  14. Chakra项目
  15. Gentoo
  16. GNU / Linux KDu

在RHEL / CentOS 6/5和Fedora 18/17中安装MariaDB数据库

我们强烈建议您使用自定义MariaDB的YUM( 包管理器 )存储库进行安装。 创建/etc/yum.repos.d/MariaDB.repo下一个回购文件,文本及根据其粘贴以下项。

添加MariaDB YUM存储库

目前,适用于RHEL 6,RHEL5,CentOS 6的 ,CentOS 5的 ,和Fedora 20,19,18,17 MariaDB的仓库。 请选择正确存储库添加到您的操作系统版本。

在RHEL 6 32位上
# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:29 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/rhel6-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在RHEL 6 64位上
# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:30 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/rhel6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在RHEL 5 32位上
# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:31 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/rhel5-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在RHEL 5 64位上
# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:31 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/rhel5-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在CentOS 6 32位
# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:21 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在CentOS 6 64位
# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:22 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在CentOS 5 32位
# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:23 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos5-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在CentOS 5 64位
# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:23 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos5-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在Fedora 20 32位
# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:34 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora20-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在Fedora 20 64位
# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:35 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora20-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在Fedora 19 32位
# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:31 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora19-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在Fedora 19 64位
# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:34 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora19-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在Fedora 18 32位
# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:32 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora18-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在Fedora 18 64位
# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:33 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora18-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在Fedora 17 32位
# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:33 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora17-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
在Fedora 17 64位
# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:33 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora17-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

一旦你已经划归/etc/yum.repos.d/ MariaDB.repo文件。 让我们安装使用以下命令YUM。

# On RHEL/CentOS 6/5 and Fedora 19,18,17 #
[root@youcl]# yum -y install MariaDB MariaDB-server
# On Fedora 20 #
[root@youcl]# yum -y install mariadb mariadb-server

如果没有安装MariaDB的GPG签名密钥,YUM会自动下载所有软件包之后安装。

启动MariaDB

安装完成后,用以下命令启动MariaDB的

# On RHEL/CentOS 6/5 and Fedora 19,18,17 #
[root@youcl]# /etc/init.d/mysql start
# On Fedora 20 #
[root@youcl]# systemctl start mariadb.service 
[root@youcl]# systemctl enable mariadb.service
登录MariaDB

在终端键入“MySQL的命令。 默认密码的根是空白。

[root@youcl]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.32-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)]>
查看现有数据库

运行以下命令查看安装附带的默认数据库。

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

键入从命令提示符下退出到退出外壳。

MariaDB [(none)]> quit
Bye
后安装MariaDB

安装后,你应该阅读及以下各认真步骤,这将设置root密码删除匿名用户禁止远程root登录并取下测试数据库和访问安全MariaDB的

[root@youcl yum.repos.d]#  mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
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!
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!
重新启动MariaDB和Connect

一旦安装后脚本完成后,您需要重新启动数据库MariaDB的采取新的变化。

# On RHEL/CentOS 6/5 and Fedora 19,18,17 #
[root@youcl]# /etc/init.d/mysql restart
# On Fedora 20 #
[root@youcl]# systemctl restart mariadb.service 

设置MariaDB的开始就启动

[root@youcl yum.repos.d]# chkconfig mysql on

让我们尝试连接新设置的根证书,我们应该看到像。

[root@youcl yum.repos.d]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.32-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)]>

在Debian 7/6和Ubuntu 13.04 / 12/10 / 12.04中安装MariaDB数据库

我们强烈建议使用自定义存储库进行安装。 运行以下命令来MariaDB的添加到您的系统。 请注意,同时导入相同的签名密钥会保持在DebianUbuntu一样。

在Debian 7 Wheezy和Debian 6挤压
narad@narad-youcl:~$ sudo apt-get install python-software-properties
narad@narad-youcl:~$ 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
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/debian wheezy main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/debian wheezy main
在Debian 6挤压
# MariaDB 5.5 repository list - created 2013-08-11 15:17 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/debian squeeze main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/debian squeeze main
在Ubuntu 13.10 Saucy
# MariaDB 5.5 repository list - created 2014-03-19 06:47 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/ubuntu saucy main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/ubuntu saucy main
在Ubuntu 13.04 Raring
# MariaDB 5.5 repository list - created 2013-08-11 15:18 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/ubuntu raring main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/ubuntu raring main
在Ubuntu 12.04 Quantal
# MariaDB 5.5 repository list - created 2013-08-11 15:24 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/ubuntu quantal main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/ubuntu quantal main
在Ubuntu 12.04精确
# MariaDB 5.5 repository list - created 2013-08-11 15:24 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/ubuntu precise main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/ubuntu precise main

一旦你正确导入密钥并适当补充仓库,可以用如图所示apt-get命令安装MariaDB的 在安装过程中你可能会问到的设置root的密码数据库。

narad@narad-youcl:~$ sudo apt-get update
narad@narad-youcl:~$ sudo apt-get install mariadb-server

设置MariaDB root密码

输入MariaDB root密码

登录MariaDB

登录MariaDB的与先前设置的根证书。

narad@narad-youcl:~$ sudo mysql -u root -p
[sudo] password for narad: 
Enter password:
MariaDB提示符
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 42
Server version: 10.0.3-MariaDB-1~raring-log mariadb.org binary distribution
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)]>
查看现有数据库
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

:键入从命令提示符下退出到退出数据库。

参考链接

  1. MariaDB与MySQL - 功能
  2. MariaDB文档
  3. MariaDB首页
赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

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

支付宝扫一扫打赏

微信扫一扫打赏