Mac上安装mariadb

1、查看mariadb包信息

# brew info mariadb

mariadb: stable 10.2.6 (bottled)
Drop-in replacement for MySQL
https://mariadb.org/
Conflicts with: mariadb-connector-c, mysql, mysql-cluster, mysql-connector-c, mytop, percona-server
/usr/local/Cellar/mariadb/10.1.23 (594 files, 155.5MB) *
  Poured from bottle on 2017-05-14 at 17:49:24
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mariadb.rb
==> Dependencies
Build: cmake ✔
Required: openssl ✔
==> Options
--with-archive-storage-engine
	Compile with the ARCHIVE storage engine enabled
--with-bench
	Keep benchmark app when installing
--with-blackhole-storage-engine
	Compile with the BLACKHOLE storage engine enabled
--with-embedded
	Build the embedded server
--with-libedit
	Compile with editline wrapper instead of readline
--with-local-infile
	Build with local infile loading support
--with-test
	Keep test when installing
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

MySQL is configured to only allow connections from localhost by default

To connect:
    mysql -uroot

To have launchd start mariadb now and restart at login:
  brew services start mariadb
Or, if you don't want/need a background service you can just run:
  mysql.server start

2、安装mariadb

# brew install mariadb

3、运行Installer

# unset TMPDIR
# cd /usr/local/Cellar/mariadb/10.1.23/
# mysql_install_db

4、启动服务(包信息中有说明如何启动)

后台启动,并且开机自启动
# brew services start mariadb
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 10 (delta 0), reused 5 (delta 0), pack-reused 0
Unpacking objects: 100% (10/10), done.
Tapped 0 formulae (37 files, 51.1KB)
==> Successfully started `mariadb` (label: homebrew.mxcl.mariadb)

前台启动
# mysql.server start
Starting MySQL
.170529 21:36:17 mysqld_safe Logging to '/usr/local/var/mysql/bogon.err'.
170529 21:36:17 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
 SUCCESS!

5、Secure the Installation

# mysql_secure_installation

6、查看版本

# mysql -uroot -p
MariaDB [(none)]> select @@version;
+-----------------+
| @@version       |
+-----------------+
| 10.1.23-MariaDB |
+-----------------+
1 row in set (0.00 sec)
原文地址:https://www.cnblogs.com/keithtt/p/6919168.html