0

A few months ago I installed either MySQL or MariaDB via Homebrew. But I don't remember exactly which one. Now I am trying to figure it out, because MariaDB supports features that MySQL does not, such as CHECK CONSTRAINTS:

CONSTRAINT random_assignment_check CHECK (LENGTH(random_assignment_id) = 5)

When I enter

SHOW CREATE TABLE employees\G;

It does not show the CHECK CONSTRAINT I created during the CREATE TABLE statement. This makes me believe I am using MySQL. Plus when I do this:

$ mysql -h localhost -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.24 Homebrew

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

This increases my suspicions even more that I am using MySQL. It clearly states 'Welcome to MySQL Monitor' and 'Copyright Oracle'.

I output info for both of them:

$ brew info mysql
mysql: stable 8.0.13 (bottled)
Open source relational database management system
https://dev.mysql.com/doc/refman/8.0/en/
Conflicts with:
  mariadb (because mysql, mariadb, and percona install the same binaries.)
  mariadb-connector-c (because both install plugins)
  mysql-cluster (because mysql, mariadb, and percona install the same binaries.)
  mysql-connector-c (because both install MySQL client libraries)
  percona-server (because mysql, mariadb, and percona install the same binaries.)
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb

MariaDB output:

$ brew info mariadb
mariadb: stable 10.3.12 (bottled)
Drop-in replacement for MySQL
https://mariadb.org/
Conflicts with:
  mariadb-connector-c (because both install plugins)
  mysql (because mariadb, mysql, and percona install the same binaries.)
  mysql-cluster (because mariadb, mysql, and percona install the same binaries.)
  mysql-connector-c (because both install MySQL client libraries)
  mytop (because both install `mytop` binaries)
  percona-server (because mariadb, mysql, and percona install the same binaries.)
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mariadb.rb

Notice for MariaDB it says installed version is 10.3.12. CHECK CONSTRAINTS were added in version 10.1, so I should have access to this feature. However, I think I am using MySQL and not MariaDB. How can I remedy this issue so I can use MariaDB and its features supported in 10.1?

  • what does type mysql return? – nohillside Jan 24 at 16:57
  • @nohillside type mysql mysql is /usr/local/opt/mysql@5.7/bin/mysql – Donato Jan 24 at 17:07
0

You can identify what you've installed with homebrew with the list option:

$ brew list

To identify which you have, if the above doesn't help you can check the mysql binary version:

$ mysql --version
mysql  Ver 15.1 Distrib 10.3.12-MariaDB, for osx10.14 (x86_64) using readline 5.1 

And after logging into the database, you can see what output you get:

$ mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.3.12-MariaDB Homebrew

And - you can check which it's using as follows:

SHOW VARIABLES LIKE "%version%";

Then version and version_comment. Should be something like:

| version | 10.1.29-MariaDB |

| version_comment | MariaDB Server |

The database consists of both the server that's running, and the client.

You can force the client you want my using the full path - something like:

/usr/local/Cellar/mariadb/10.3.12/bin/mysql

You can check the server you're running with a ps:

$ ps -ef | grep mysqld
  501 95347     1   0 12:07PM ??         0:00.02 /bin/sh /usr/local/Cellar/mariadb/10.3.12/bin/mysqld_safe --datadir=/usr/local/var/mysql --pid-file=/usr/local/var/mysql/server.pid
  501 95411 95347   0 12:07PM ??         0:00.40 /usr/local/Cellar/mariadb/10.3.12/bin/mysqld --basedir=/usr/local/Cellar/mariadb/10.3.12 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mariadb/10.3.12/lib/plugin --log-error=/usr/local/var/mysql/server.err --pid-file=/usr/local/var/mysql/server.pid

Here you can see the start script is running (first line), and has called the actual server binary (second line). Both are running the mariadb instance.

The two packages will conflict with each other and shouldn't be installed at the same time. The conflict is called out in the brew recipe.

  • How do I force the use of MariaDB instead of MySQL if both are installed? – Donato Jan 24 at 17:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .