Magento2 No such file or directory

在Mac上安装了Mamp 之后运行Magento2的相关命令 ,出现下面问题。

ysq@yangshuqiudeMacBook-Pro magento-ce-2.3.6_sample_data % php bin/magento setup:static-content:deploy -f
Deploy using quick strategy
Error happened during deploy process: SQLSTATE[HY000] [2002] No such file or directory

解决办法:执行下面命令,前提是已经配置了php的版本,请查看设置php版本的方法

source ~/.bash_profile

查看php的版本。

ysq@yangshuqiudeMacBook-Pro magento-ce-2.3.6_sample_data % php -v
WARNING: PHP is not recommended
PHP is included in macOS for compatibility with legacy software.
Future versions of macOS will not include PHP.
PHP 7.3.24-(to be removed in future macOS) (cli) (built: Nov 23 2020 06:45:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.24, Copyright (c) 1998-2018 Zend Technologies
ysq@yangshuqiudeMacBook-Pro magento-ce-2.3.6_sample_data % source ~/.bash_profile
ysq@yangshuqiudeMacBook-Pro magento-ce-2.3.6_sample_data % php -v
PHP 7.2.22 (cli) (built: Feb 17 2020 12:36:08) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
ysq@yangshuqiudeMacBook-Pro magento-ce-2.3.6_sample_data % php -v
操作示例