In order to export & import an SQL dump using MAMP on macOS, the following Terminal.app commands can be used with the “mysqldump” (export) & “mysql” (import) tools located in MAMP’s /bin/ folder:

MAMP MySQL dump export

Alternatively – in order to keep backwards-compatibility to older MySQL versions – the option “–compatible=mysql40” can be added:

$ ./mysqldump --compatible=mysql40 --host=localhost -uroot -proot source_database > ~/Desktop/database_name-dump.sql

This will dump the defined database (source_database) into a file named “database_name-dump.sql” to the current macOS user’s Desktop.

MAMP MySQL dump import

In order to import an exported SQL dump into (another) database “target_database“, the following command can be used:

 

Share:
  • 0
  • 1

Questions? Suggestions? Let us know with a comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.