Problem Description
- You wish to run Magento commands via CLI
- When you run a command like php -d memory_limit=1G bin/magento setup:upgrade it results in an SQL error: SQLSTATE[HY000] [2002] No such file or directory
Problem Resolution
Open the file app/etc/env.php and change the db => connection => default => host value from 'localhost' to '127.0.0.1'
Save the file, and attempt your command again.