PHP memory limit error when importing a SQL file in Adminer

I’m trying to import a website in to local and I receive the following error message when trying to import the database via Adminer:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 188123800 bytes) in /Applications/ on line 97

I’ve tried the suggestions in another forum topic on this but neither of the command line suggestions in there work. Both return the message “No such file or directory”

Are there any other workarounds that I can try?

That error is basically saying that PHP (the underlying software running Adminer) didn’t have enough memory to handle the upload of that SQL file.

Are you able to import the site by creating a zip of the sql file along with the wp-content folder? Something like what’s outlined in the “Restoring From Only Local Site files” section of this help doc:

If you do need to manually import the database of a large SQL file, I recommend using the terminal since it is much more efficient and doesn’t run into these sorts of memory issues. To do this:

  1. Copy the sql file to the site root. That location should be something like: ~/Local Sites/sitename/app/public/

  2. Right-click on the site in Local and select “Open site shell”

  3. Within the terminal that opens, import the sql file using this command:

    wp db import name-of-sql-file.sql
  4. Since this is being done manually, you’ll likely need to search for the old domain and replace it with the new domain. That command looks something like:

    wp search-replace '//' '//example.local'

Can you let us know if either of those workflows gets you what you need?

Thank you for your quick reply Ben. I’ve had some success with importing via the terminal.

The database (188mb) has been imported successfully. However the search and replace command returned 0 replacements when run in the terminal. As a result I still get an error when trying to access wp-admin.

I’ve updated the wp-config file to the following but it still isn’t working:
define(‘DB_NAME’, ‘local’);
define(‘DB_USER’, 'root);
define(‘DB_PASSWORD’, ‘root’);
define(‘DB_HOST’, ‘localhost’);

The wp-admin login has been replaced by alternative login url, would this have any effect?

When running the search and replace command, you’ll need to update it to the actual urls for the remote site ( and the local site (example.local)

When you ran the search-replace command, where there any errors that showed up?

One way to see what the current url is within the local database is to run this command:

wp option get siteurl

From there, you should be able to use that within the search-replace command.

Hi Ben,
Thanks, I didn’t realise that I had to include the full and http://mysite.local in the search and replace command. I thought that // and //mysite.local would work. It has now made 24,500 replacements.
Thanks for your help with this.

1 Like

Usually I just do the regular // when I do the search and replace. I’ll only include the https:// part if I know I need to change the protocol from secure to regular HTTP.

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.