Error: Cannot connect to MySQL server on 'localhost' during wp db import in Local Site Shell

Thanks for the screenshot, @farhan.

You can try making the change below to append the port number in your wp-config.php:

  1. In Local, visit your site and note the port number on the Database tab.

  2. Edit your site’s wp-config.php file, replacing this line:

    define( 'DB_HOST', 'localhost' );

    With localhost and the port number:

    define( 'DB_HOST', 'localhost:[your-port-number-here]' );

    For example, assuming 10061 is the port number from the database tab:

    define( 'DB_HOST', 'localhost:10061' );
  3. Try running wp db import local.sql again. (You should not need to append the --ssh flag.)