Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure MAMP to use mariadb

I successfully installed mariadb, but MAMP continues to use the copy of mysql located in its bin folder; specifically:

/Applications/MAMP/Library/bin/mysql

How do I get MAMP to use mariadb, which in my case is located in /usr/local/bin/mysql?

I tried creating a symbolic link in MAMP's bin folder to point to /usr/local/bin, but that didn't work. Hmm.

like image 954
venutip Avatar asked Jun 23 '11 03:06

venutip


2 Answers

MAMP uses MAMP/bin/startMysql.sh to start mysql. Try to change it.

like image 173
simply_ru Avatar answered Nov 15 '22 12:11

simply_ru


here's how i do it so that you can use either mysql or mariadb since mariadb is a drop in replacement (typing this from memory, so please let me know if there are some mistakes)...

0) make a backup of your mysql db dir just in case, and do some mysql prep just in case

$ cp -R /Applications/MAMP/db/mysql /Applications/MAMP/db/mysql.2013-02-06-1850.bak
$ /Applications/MAMP/bin/repairMysql.sh
$ /Applications/MAMP/bin/quickCheckMysqlUpgrade.sh
$ /Applications/MAMP/bin/upgradeMysql.sh

1) make a copy or take note of some settings in your my.cnf file. It can be located in a variety of different places, so to find them all (there are a bunch):

$ locate my.cnf
/Applications/MAMP/conf/my.cnf
/etc/my.cnf
/usr/local/etc/my.cnf
/usr/local/etc/my.cnf.d
/usr/local/etc/my.cnf.d/client.cnf
/usr/local/etc/my.cnf.d/mysql-clients.cnf
/usr/local/etc/my.cnf.d/server.cnf

2) figure out which my.cnf was loaded (for MAMP, it MAY be in /Applications/MAMP/conf/my.cnf)

$ /usr/local/bin/mysql --help | grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf 
$ /Applications/MAMP/Library/bin/mysql --help | grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /Applications/MAMP/conf/my.cnf ~/.my.cnf

3) make a backup of the my.cnf in /etc/my.cnf and edit my.cnf to make sure it's got a few parameters in there, most importantly the port, socket, and datadir settings so that mariadb will know where to look for your db files:

$ sudo cp /etc/my.conf /etc/my.cnf.2013-02-06-1858.bak
$ sudo vi /etc/my.cnf
port     = 3306
socket   = /Applications/MAMP/tmp/mysql/mysql.sock 
datadir  = /Applications/MAMP/db/mysql
tmpdir   = /Applications/MAMP/tmp/mysql

4) add any mariadb specific config options you may want in a [mariadb] section

5) install mariadb (i like using brew, but pick your poison)... and you can really do this any time

$ brew install mariadb

6) make a symbolic link from the my.conf from step two

$ sudo ln -s /Applications/MAMP/conf/my.cnf /etc/my.cnf

6a) you can put your my.cnf anywhere, as long as there's a copy or link to it in /etc/my.cnf... the goal here is to have mariadb and MAMP's implementation of mysql use the same config settings.

7) now make a shell shell script to load apache and mariadb

$ mkdir -p ~/scripts/mamp
$ touch ~/scripts/mamp/startSomething.sh ~/scripts/mamp/stopSomething.sh
$ chmod ug+rx ~/scripts/mamp/*Something.sh

8) get/take note of the current start/stop script for apache (it'll prob won't be anything fancy)

$ more /Applications/MAMP/bin/startApache.sh
$ more /Applications/MAMP/bin/stopApache.sh

9) get the installed mariadb path, and make sure it's the mariadb version

$ which mysql
/usr/local/bin/mysql
$ mysql --version
mysql  Ver 15.1 Distrib 5.5.29-MariaDB, for osx10.8 (i386) using readline 5.1

10) now edit startSomething.sh

# /bin/sh
/Applications/MAMP/Library/bin/apachectl start
/usr/local/bin/mysql.server start &

11) do the same for stopSomething.sh

# /bin/sh
/Applications/MAMP/Library/bin/apachectl stop
/usr/local/bin/mysql.server stop &

12) that's it!. to start or stop things

$ ~/scripts/mamp/startSomething.sh
$ ~/scripts/mamp/stopSomething.sh

if you want the vanilla MAMP, use the MAMP app that came with MAMP. otherwise, have fun with this slightly faster database with a bunch of fun new features... but keep in mind that while mariadb is by design a drop in replacement for mysql, it's not true the other way around (MariaDB v MySQL compatibility)

like image 28
pxl Avatar answered Nov 15 '22 13:11

pxl