Why am I getting a PDO Exception error when I try to run Drupal Console inside the root directory?
Try to update below in your php.ini. You need to define php for correct location for .sock file.

mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock


OR

If you will not getting result then try to replace below in your settings.php file.

Replace 'host' =&gt; 'localhost',

With 'host' =&gt; '127.0.0.1',