Mac下安装MariaDB

2016-06-03  本文已影响6609人  码农老王

首先安装brew, 这个就不在这赘述了. 安装教程一搜一大把

自行Google: "brew mac"

brew配置正常后输入命令:

brew install mariadb

显示如下则等待下载完成,自动安装即可

==> Downloading https://homebrew.bintray.com/bottles/mariadb-10.0.21.el_capitan.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring mariadb-10.0.21.el_capitan.bottle.1.tar.gz
==> /usr/local/Cellar/mariadb/10.0.21/bin/mysql_install_db --verbose --user=wangyu --basedir=/usr/local/Cellar/mariadb/10.0.21 --datadir=/usr/local
==> Caveats

如果提示以下则说明安装成功了

A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

To connect:
    mysql -uroot

To have launchd start mariadb at login:
  ln -sfv /usr/local/opt/mariadb/*.plist ~/Library/LaunchAgents
Then to load mariadb now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
Or, if you don't want/need launchctl, you can just run:
  mysql.server start

大致意思是你可以利用上面的命令, 来设置自启动服务.

如果你不需要自启动, 可以用mysql.server start来启动

本人是不喜欢自启动的, 所以就用mysql.server start

➜  ~ mysql.server start
Starting MySQL
. SUCCESS! 
➜  ~ 

提示如下的话, 说明启动成功了!下面开始操作数据库

➜  ~ mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.0.21-MariaDB Homebrew

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation 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)]> exit
Bye
➜  ~ 

至此,MariaDB就可以正常用了.

MariaDB跟MySQL用起来是一样一样的, 好久没有大量操作数据库, 这次想自己搞个东西, 可能以后会遇到很多坑, 这里也提醒自己到时候要及时记录下来.

最后

➜  ~ mysql.server stop
Shutting down MySQL
.. SUCCESS! 
➜  ~ 

关闭数据库

上一篇下一篇

猜你喜欢

热点阅读