How to import a large MySQL database dump into MAMP, Mac OS X

If you are using MAMP for your local WordPress or PHP development on a Mac, you likely need to import huge MySQL database dump files (more then 32Mb) in your local environment.

You could increase the size of maximum uploads in your php.ini file, however if the dump is really big (over 100Mb), the operation can take ages to complete.

It is more covenient to do this using the command line, expecially since it’s just a one liner.
mysql -u {DB_USER_NAME} -p {DB_NAME} < {PATH/TO/MYSQL/DUMP/FILE.SQL}
Keep in mind that the default user for MySQL as set by MAMP is root with a password of root, and that you need the full path to MAMP binaries to run the mysql command on a default installation. The command becomes:
/Applications/MAMP/Library/bin/mysql -u root -p {DB_NAME} < {PATH/TO/MYSQL/DUMP/FILE.SQL}
On Mac OS X you can simply drag and drop your file to the console to get the full path written for you. So you just have to:

  • Open the Terminal app;
  • Copy and paste this string to it:
    /Applications/MAMP/Library/bin/mysql -u root -p
  • Now, before you hit enter, type your MySQL database name followed by “<” and drag your SQL dump file to the Terminal so that the full path to it gets appended to the command.
  • Your command is complete! Hit enter and have faith. It will take a while for the dump to get imported.

Once the import is completed, the prompt will return. Please note that no success message is given, so go back to phpMyAdmin to verify if your data is there.