Mac中MariaDB数据库的安装步骤

 更新时间:2016年09月22日 10:31:41   作者:闪烁之狐  
大家都知道MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。这篇文章我们将详细介绍在Mac中安装MariaDB数据库的步骤,有需要可以参考学习。
(福利推荐:【腾讯云】服务器最新限时优惠活动,云服务器1核2G仅99元/年、2核4G仅768元/3年,立即抢购>>>:9i0i.cn/qcloud

(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

前言

MariaDB由MySQL的创始人Michael Widenius主导开发,他早前曾以10亿美元的价格,将自己创建的公司MySQL卖给了SUN,此后,随着SUN被甲骨文收购,MySQL的所有权也落入Oracle的手中。MariaDB名称来自Michael Widenius的女儿Maria的名字。那么在Mac中如何安装MariaDB数据库呢?下面小编就给大家介绍Mac中安装配置MariaDB数据库的方法。

MariaDB安装步骤

如果你是Mac上的开发者,通过本文你可以在OS X上通过Homebrew来简单的获取安装最新稳定版本的MariaDB,接下来我们将一步步的来指导安装MariaDB数据库,如果你的Mac中已经安装好了Xcode和Homebrew的话,则直接跳到第四步。

1. 安装Xcode

使用如下命令来安装Xcode

xcode-select --install 

2. 安装Homebrew

安装Homebrew的命令:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

3. 检查Homebrew

brew doctor 

4. 更新Homebrew

如果通过上面的命令检查到Homebrew不是最新的版本,可以通过如下命令来把Homebrew更新到最新:

brew update 

5. 确认MariaDB的版本

Homebrew仓库中确认MariaDB的版本:

brew info mariadb 

6. 安装MariaDB

通过如下命令来下载安装MariaDB:

brew install mariadb 

7. 运行数据库安装程序

分别执行下面的命令来实现安装:

unset TMPDIR 
cd /usr/local/Cellar/mariadb/10.0.10/ 
mysql_install_db 

8. 运行MariaDB

经过了上面的若干命令,已经安装好了MariaDB数据库,但是MariaDB数据库服务并没有启动,你可以通过这个命令来启动MariaDB数据库服务:

mysql.server start 

9. 安全的完成安装

通过上面的启动MariaDB数据库服务,你已经可以连接MariaDB的数据库了,但是还不够安全,通过如下步骤可以完成更全面的设置,如:重设root用户的密码、移除匿名用户、移除默认的test数据库等等

具体的执行和设置如下:

➜ 10.1.14: 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): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 
Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 
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] n 
 ... skipping.

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! 

10. 连接MariaDB数据

连接MariaDB数据库的命令:

mysql -u root -p 

11. 验证MariaDB版本

MariaDB [(none)]> select @@version; 
+-----------------+
| @@version  |
+-----------------+
| 10.1.14-MariaDB |
+-----------------+
1 row in set (0.00 sec) 

MariaDB基础命令

下面是MariaDB的一些基础使用命令:

-- 显示数据库列表
show databases;

-- 切换到名为mysql的数据库,显示该库中的数据表
use mysql; 
show tables;

-- 显示数据表table的结构
desc table;

-- 建数据库A与删数据库A
create database `database_A`; 
drop database `database_A`;

-- 建表:
use database_A; 
create table table_A(字段列表); 
drop table table_A;

-- 显示表中的记录:
select * from table_A;

-- 清空表中记录:
delete from table_A; 

总结

以上就是在Mac中安装MariaDB数据库的全部步骤,大家都学会了吗?希望这篇文章的内容对大家的学习能有所帮助,如果有疑问大家可以留言交流。

相关文章

  • 在Ubuntu系统中安装MariaDB数据库的教程

    在Ubuntu系统中安装MariaDB数据库的教程

    这篇文章主要介绍了在Ubuntu系统中安装MariaDB数据库的教程,同时也适用于其他Debian系的Linux系统,需要的朋友可以参考下
    2015-06-06
  • 详谈MySQL和MariaDB区别与性能全面对比

    详谈MySQL和MariaDB区别与性能全面对比

    这篇文章主要介绍了详谈MySQL和MariaDB区别与性能全面对比,需要的朋友可以参考下
    2020-02-02
  • CentOS 7中成功安装MariaDB的方法教程

    CentOS 7中成功安装MariaDB的方法教程

    这篇文章主要给大家介绍了CentOS 7中成功安装MariaDB的方法教程,文中通过图文介绍的非常详细,对大家具有一定的参考价值,需要的朋友们可以参考学习,下面来一起学习学习吧。
    2017-04-04
  • 关于MariaDB安装问题小记(CMake Error at)

    关于MariaDB安装问题小记(CMake Error at)

    这篇文章主要介绍了今日在安装MariaDB的时候始终提示如下错误,但是我已经安装了libaio-devel库,需要的朋友可以参考下
    2014-12-12
  • Window7安装MariaDB数据库及系统初始化操作分析

    Window7安装MariaDB数据库及系统初始化操作分析

    这篇文章主要介绍了Window7安装MariaDB数据库及系统初始化操作,简明扼要的分析了Windows7平台上安装mariadb数据库的步骤、配置方法及相关注意事项,需要的朋友可以参考下
    2018-05-05
  • centos 7安装mysql5.5和安装 mariadb使用的命令

    centos 7安装mysql5.5和安装 mariadb使用的命令

    以前的Linux系统中数据库大部分是mysql,不过自从被sun收购之后,就没用集成在centos这些开源Linux系统中了,那么如果想用的话就需要自己安装了,在安装过程中肯定会用到些命令,下面通过本篇文章给大家介绍centos 7安装mysql5.5和安装 mariadb使用的命令
    2015-09-09
  • 我是如何用2个Unix命令给MariaDB SQL提速的

    我是如何用2个Unix命令给MariaDB SQL提速的

    我试图在 MariaDB(MySQL)上运行一个简单的连接查询,但性能简直糟糕透了。下面将介绍我是如何通过两个简单的 Unix 命令,将查询时间从 380 小时降到 12 小时以下的,需要的朋友可以参考下
    2018-08-08
  • mariadb的主从复制、主主复制、半同步复制配置详解

    mariadb的主从复制、主主复制、半同步复制配置详解

    这篇文章主要详细介绍了mariadb的主从复制、主主复制、半同步复制的概念和方法,有需要的小伙伴可以参考下
    2016-11-11
  • MariaDB中的thread pool详细介绍和使用方法

    MariaDB中的thread pool详细介绍和使用方法

    这篇文章主要介绍了MariaDB中的thread pool详细介绍和使用方法,thread pool对高并发的环境是很好的一个解决方法,需要的朋友可以参考下
    2014-07-07
  • MariaDB配置双主复制方案

    MariaDB配置双主复制方案

    MySQL复制中较常见的复制架构有“一主一从”、“一主多从”、“双主”、“多级复制”和“多主环形机构”等,今天我们来详细探讨下MariaDB配置双主复制的方案
    2017-03-03

最新评论

?


http://www.vxiaotou.com