Create file named info.php in your WordPress root folder with the following PHP function:
<?php phpinfo(); ?>
Check the http://yourdomain.com/info.php details and search for pdo_mysql.default_socket. Here You will find the value that You need>
Change your DB_HOST value in the wp-config.php file from localhost to
/** MySQL hostname */ define( 'DB_HOST', 'localhost:/Users/YOUR_MACOS_USERNAME/Library/Application Support/Local/run/VALUE_FROM_PHP_INI/mysql/mysqld.sock'
YOUR_MACOS_USERNAME – whatever your username that you log into your computer with.
VALUE_FROM_PHP_INI – Click the (i) icon next to the version of PHP in Local. Once the php info page loads in your browser, search the page for “Loaded Configuration File”. You should see something like /Users/xxx/Library/Application Support/Local/run/JVTSp1q91/conf/php/php.ini. Grab the random set of characters between “run/” and “/conf”. In my example, JVTSp1q91.