Importing A Large Database in MAMP

Importing A Large Database in MAMP

When working with WordPress databases, we’re pretty fortunate to have tools like WP Migrate DB ProphpMyAdminSequel Pro, and so on. But there are times when importing a large database is a bit more demanding than the front-end utilities we have.

Perhaps we have to change up our PHP configuration, perhaps we’re dealing with hundreds of megabytes worth of data, perhaps we don’t have the kind of control on the environment that we need.

Whatever the case, we always have the command line. And if you’re working with any CMS with MAMP, and you’re faced with importing large databases, then you may need to stop tweaking your PHP settings and simply import the file via the command-line.

Importing A Large Database

One of the first questions that often comes up when having to do this is:

Why can’t I just use a front-end?

Technically, you can. It may take a lot of tweaking, but if you can…

  • get the environmental variables configured in such a way that a request won’t time out,
  • define a value such that a large enough upload is permitted,
  • and the software won’t opt to cut you off because it thinks something is broken because of the time that has passed

Then you may be okay and this post isn’t for you, but if that’s not the situation you find yourself working in, then here’s how you can go about importing a large database using an SQL file and the command line.

1. Grab The SQL File

This post assumes you have a copy of the SQL file you’re trying to import. This is something you can usually grab from the server, from whoever has hired you, or whatever system it is with which you’ll be working.

SQL export

Ultimately, the goal is to replicate the production environment on your local machine so you can make the necessary changes and then have what you need to deploy to the staging environment or back to the production environment.

2. Connect To The Database

If you’re running MAMP, then you’re going to need to navigate to the MySQL executable. You’ll need to launch your command-line then navigate to the following path (or similar path depending on your setup and when you’re reading this):

$ cd /Applications/MAMP/Library/bin

From there, you can connect to your MySQL server (assuming it’s running) by entering the following command:

$ ./mysql -uroot -proot

And then you’ll be presented with the MySQL command-line:


At this point, you’ll need to connect to the database into which you want to import your file. To do this, simply enter the following at the mysql>;prompt:

connect your_database_name

Then it’s time to actually import the file.

3. Import The Export

Next, simply enter the following command:

source /path/to/your/file/sql_export.sql

And let MySQL do its thing.

SQL import

And when it’s done, it will return you to the command prompt.

Bypassing The Time

And with that, you’ve bypassed all the usual headaches of having to configure an environment just to import a single file and you’ve still got your development environment setup so you can access the database with your front-end of choice.


(Article taken from:


The content of this field is kept private and will not be shown publicly.
Your email address will be kept private and will not be shown publicly.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.