title: MAMP (mysql) over LAN
body: <p>I have found some posts which explain how to setup mysql in MAMP for lan use. Each explanation describe that my.cf needs to be changed so the bind-adress is set to lan ip or 0.0.0.0 which is preferred.</p>
  
  <p>The strange thing is that when i do so, after starting MAMP again, it changes bind-adress back to 127.0.0.1.</p>
  
  <p>I really need to set up a mysql for lan usage, so all team members will be working towards same DB.
  Anyone know a good way och a working way in MAMP ?</p>
  
  <h2>Solution</h2>
  
  <p>So ive found a solution and here are steps i took on OS X 10.6:</p>
  
  <p>Scenario: My local Mamp setup (computer 1) needs to access Mamps mySQL server over lan on computer 2. All changes mentioned below are made on the remote server, that means computer 2.</p>
  
  <ol>
  <li><p>Mamp File-menu > Edit template... > MySQL my.cnf</p></li>
  <li><p>Make the change to bind adress:<br>
  <code># The MySQL server<br>
  [mysqld]<br>
  port = 3306<br>
  socket = /Applications/MAMP/tmp/mysql/mysql.sock<br>
  key_buffer = 16M<br>
  max_allowed_packet = 1M<br>
  table_cache = 64<br>
  sort_buffer_size = 512K<br>
  net_buffer_length = 8K<br>
  read_buffer_size = 256K<br>
  read_rnd_buffer_size = 512K<br>
  myisam_sort_buffer_size = 8M<br>
  bind-address=0.0.0.0</code></p></li>
  <li><p>Save <strong><em>my.cnf</em></strong> and close the editor</p></li>
  <li><p>Now open terminal and type: <strong><em>netstat -an | grep 3306</em></strong> and you should see something like this:<br>
  <strong>tcp4 0 0 *.3306  <em>.</em> LISTEN</strong>
  If you now try to connect (eg. your local WordPress to the remote mySQL server then you probably end up with some error because of user privileges)</p></li>
  <li><p>Add new user to the remote mySQL-server. Head now over to your phpMyAdmin page on the remote computer via Mamp WebStart button and click on <strong>Privileges</strong>. Fill out the textfields, skip <strong>Database for user</strong> and check for all checkboxes in <strong>Global privileges</strong> EXCEPT <em>Administration</em> cause those are not needed OR what privileges you want this user to have. When done, hit <strong>OK</strong> at the bottom</p></li>
  </ol>
  
  <p><em>(Note: as host, while creating new user in mysql server leave it empty if you want all users in same LAN to access that particular sql account)</em></p>
  
  <p>Now, you should be ok to run. Head back to your own mac (computer 1) and if you are using this for WP development, edit your <em>wp-config.php</em> and fill in host as lan-ip, user and pass as you just entered in remote (computer 2) server</p>
  
  <p><img src="https://i.stack.imgur.com/G0ufF.png" alt="demo screenshot"></p>