Wordpress Import (CLI) returns Error Establishing a database connection

I am trying to use the wp import cli in the terminal to import a large wxr file (200MB) from the old test server to new test server. I can login to wp-admin using the admin account and mysql cli mysql -u user -p so I know that my db information is correct. But when I use wp import command, returns db error Error Establishing a database connection. Is there any part that I am missing? I am checking other SO questions and other website articles but no luck so far.

Note:

  1. Old server runs http and New Server runs https
  2. Old and New Server has user and password

Regarding note 2, I don't think it matters since I was able to import from test server to my local server without problems before.

The complete error message when I turn on debug is :

PHP Warning:  mysqli_real_connect(): (HY000/2002): No such file or directory in /project-path/wp-includes/wp-db.php on line 1653
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /project-path/wp-includes/wp-db.php on line 1653
Error: Error establishing a database connection.

Wordpress 5.6

Update: Found the solution with this SO.

Topic wp-cli import Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.