I am trying to install MariaDB on my Mac using brew. However, I am struggling to get this installed due to it conflicting with MySQL. I was wondering whether anyone can advise how to set it up so I have both MariaDB and MySQL as I will need both on my machine as I work on multiple projects which need to use one or the other.
3x-iMac:~ admin$ mysql.server start
Starting MariaDB
SUCCESS!
3x-iMac:~ admin$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 8.0.11 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
3x-iMac:~ admin$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 8.0.11 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> \s
--------------
mysql Ver 15.1 Distrib 10.3.8-MariaDB, for osx10.13 (x86_64) using readline 5.1
Connection id: 24
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MySQL
Server version: 8.0.11 MySQL Community Server - GPL
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 2 hours 47 min 30 sec
Threads: 6 Questions: 1257 Slow queries: 0 Opens: 154 Flush tables: 2 Open tables: 130 Queries per second avg: 0.125
--------------
The problem with having both MySQL and MariaDB installed simultaneously is not so much the conflicting port (both servers bind to port 3306 by default), because that could be changed in the server configuration. The problem rather is that MariaDB is a drop-in replacement for MySQL and thus uses the same paths and names for the binaries (e.g. mysqld for the server, mysql for the client). So they are designed that way that one has either one or the other installed, but not both at the same time.
A better approach would be to set up a Docker container for both database servers and use that. This approach also has the charm that one could also run several different versions of both database servers, if that is desired. You still have to map the each container to a different port, though.
A simple
docker-compose.ymlto set up MySQL 5 and MariaDB 10 could look like this:You can start both containers by typing
docker-compose up -dinto the terminal in the directory of thedocker-compose.ymlfile, given that docker-compose is installed on your system.MySQL 5 would be available on port 3305, MariaDB on port 3310. (That would leave the possibility to have a native MySQL or MariaDB on port 3306.) The environment variables for database users, passwords and names of the databases should be adjusted, of course. Same goes for the versions of MySQL and MariaDB, if you need different versions.
After the containers are up (
docker-compose up -d) you can connect to them e.g. via:(Take care that you give the correct port argument. In this case, port 3310 is for MariaDB 10.)
After typing the password for the user
useryou can issue your SQL queries:Have fun!