Cannot import database through SSH

Issue Summary

I’ve come here because Google isn’t helping. I’m attempting to install a manual backup of an old website because the owners asked me to extract some info. the problem is that the database is 430mb and it won’t import. A google search brought me to a thread that says to place the database file in the “app” directory, open SSH (which I think is Shell" and type a command with the database name to import it via command. Only it keeps on telling me that it cannot find the path. What can I do?

Is it telling you something like the below?

Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /Users/username/Sites/sitename/app/public/wp-includes/wp-db.php on line 1653

And are you on a recent version of Local (Lightning)?
Are you on a mac?

You may need to add the socket path to your wp-config.php file. The socket path can be found in Local under the database tab of the site panel:

Copy the whole thing:
/Users/username/Library/Application Support/Local/run/SITECODE/mysql/mysqld.sock

And past it following a colon after localhost in the DB_HOST setting in /wp-config.php:
define( 'DB_HOST', 'localhost:/Users/username/Library/Application Support/Local/run/SITECODE/mysql/mysqld.sock' );

WP_CLI will start to work in Terminal / Shell / SSH, and you should be able to import a 430 mb database without much trouble. It will probably take a while though. Useful commands:

Export the existing database just in case:
wp db export local.sql

Reset the database before import:
wp db reset

Import the new database and wait:
wp db import wp_database_name.sql

Hi, sorry, I was away!

Yes, I’m on the most recent version of Local but runningn Windows 10.

The error was similar but less detailed. It simply said it couldn’t find the file or directory.

I’ve attemped the command you gave me, as the only one I found came from an older post but now it’s only telling me ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)

I do not have the soccket in that position.

Sorry. I am worried mac is different. It sounded very similar to my issue. I have had something like that error, but it was because the MySQL server had stopped on my machine, and I had to restart it. I am probably not going to be much help on Windows though. Have you tried completely restarting the machine? :grimacing:

Exact same issue.

Hey @emsixteen

It looks like this is a bug with how Local is setting up the shell environment.

As a work around, you can manually update the wp-config.php for the site to include the port number for the database:

I’ll file a bug with the Local bug tracker so that we can get someone to look into and fix this!


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