100

I can't seem to find the my.cnf or other config file for the MySQL that comes with MAMP. Does it not include one?

Darryl Hein
  • 142,451
  • 95
  • 218
  • 261

6 Answers6

209

The MySQL server of MAMP (not PRO) will be started without any my.cnf file. But you can create your own my.cnf file.

  1. Stop servers
  2. Create a my.cnf file in /Applications/MAMP/conf/
  3. Add your content in to my.cnf
  4. Save my.cnf
  5. Start servers

You do not have to put a complete configuration in the my.cnf file. You can just add parts of a configuration ... for example:

[mysqld]
max_allowed_packet = 64M
Darryl Hein
  • 142,451
  • 95
  • 218
  • 261
Dirk Einecke
  • 2,335
  • 1
  • 15
  • 11
  • 17
    Note that MAMP Pro will create its own version. You can edit it more "nicely," though it's a bit of a pain for people used to the command line. Just go File->Edit Template->MySQL my.cnf, and change whatever settings you need. More info on both MAMP and MAMP pro [here](http://blog-en.mamp.info/2010/02/how-to-set-mysql-default-storage-engine.html). – Chris Krycho Apr 06 '12 at 18:46
  • 1
    Manually adding the my.cnf file to Application/MAMP/conf/ solved ERROR 2006 (HY000) at line 1357: MySQL server has gone away. This post is old but still relevant for MAMP Version 3.0.2 (not pro) – C13L0 Mar 16 '14 at 19:25
  • 21
    +1 for the `max_allowed_packet`. How did you know **exactly** what I was looking for? – Igbanam Sep 29 '14 at 11:27
  • 4
    Thanks for including the [mysqld] line. I was missing that and banging my head against the wall why MAMP couldn't start up. – Brendan Falkowski May 11 '15 at 17:20
  • 1
    @Yasky, well, looks like at least 15 people that use MAMP have probably encountered '#2006 MySQL server has gone away', googled it, found [this](http://stackoverflow.com/questions/7942154/mysql-error-2006-mysql-server-has-gone-away) SO question, and then came here to find out where the my.cnf file is! – thephpdev Nov 18 '16 at 13:29
  • I use MAMP 5.3 and have my.cnf in the following locations but they are all ignored obviously (yes i restarted the mysql service): ./MAMP/Library/my.cnf ./MAMP/my.cnf ./MAMP/apache/my.cnf – Achim Koellner Nov 30 '19 at 01:52
  • Thank you, I've spent all day trying to figure this out. I flushed the cache of my drupal 8 project and it gave this error 'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away'. Above was the correct solution. – Travis Smith Jan 15 '20 at 22:11
11

Some standard my.cnf variants can be found at /Applications/MAMP/Library/support-files/

Invoking mysqld --verbose --help | less on the MAMP mysqld binary reports:

Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /Applications/MAMP/conf/my.cnf ~/.my.cnf

Copy one of the variants in /Applications/MAMP/Library/support-files/ to one of the locations in mysqld's search order above, and you should be good to go after restarting the daemon.

Dmitry Minkovsky
  • 36,185
  • 26
  • 116
  • 160
10

Since MAMP server generates my.cnf dynamically on MAMP server startup, it's best to use the following steps to add or edit the MySQL configuration:

  1. Stop MAMP server
  2. Goto Files > Edit Template > MySQL
  3. Make the necessary changes and save
  4. Restart MAMP

I tried this on MAMP PRO 3.5.

Darryl Hein
  • 142,451
  • 95
  • 218
  • 261
sreeraj
  • 101
  • 1
  • 3
9

For MAMP 3.5 on Mac El Capitan, only this worked for me:

  1. Stop servers
  2. Create a my.cnf file in /Applications/MAMP/Library/
  3. Add your content into my.cnf like

    [mysqld] max_allowed_packet = 64M

  4. Save my.cnf

  5. Start servers

Not required to change ownership of file, it should work. Verify by running SHOW VARIABLES in phpmyadmin and look for your changed setting.

Darryl Hein
  • 142,451
  • 95
  • 218
  • 261
Mirza Vu
  • 1,532
  • 20
  • 30
2

No, it doesn't come with the my.cnf file

L. Cosio
  • 227
  • 3
  • 9
1

I found that MAMP PRO will create a my.cnf by default on startup under the MAMP/tmp directory if a ~/my.cnf is not provided ... grepping ps aux you may find the default location under /Applications/MAMP/tmp/my.cnf ...

 ps aux | grep mysql

Which provided the following...

root       284   0.0  0.1  2435544    532   ??  Ss    12:00AM   0:00.06 /bin/sh     /Applications/MAMP/Library/bin/mysqld_safe 
--defaults-file=/Applications/MAMP/tmp/mysql/my.cnf 
--port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock 
--user=mysql --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid 
--log-error=/Applications/MAMP/logs/mysql_error_log.err 
--tmpdir=/Applications/MAMP/tmp/mysql/tmpdir 
--datadir=/Library/Application Support/appsolute/MAMP PRO/db/mysql
Edward J Beckett
  • 5,061
  • 1
  • 41
  • 41