Question

I'm trying to create a module on a local installation of Magento 2.1.4.

i'm getting this error when running bin/magento setup:upgrade:

[Zend_Db_Adapter_Exception]                       
SQLSTATE[HY000] [2002] No such file or directory  

[PDOException]                                    
SQLSTATE[HY000] [2002] No such file or directory  

setup:upgrade [--keep-generated] [--magento-init-params="..."]

After this i tried this solution: Cannot create new module in magento2 - php bin/magento setup:upgrade

The outcome was the same and there is not much explanation on what this did to solve the problem.

I also read solutions from almost a year ago when apparently this was a common issue deleting var/cache, var/generation and var/di but that didn't worked either.

Was it helpful?

Solution

Simple, try the following commands. I have encountered this error, and I have overcome.

rm -rf var/di/* 
rm -rf pub/static/_cache/* 
rm -rf pub/static/frontend/*
rm -rf var/generation/* 
rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf var/view_preprocessed/*

In magento 2

var/di has been replaced by generated/metadata

var/generation has been replaced by generated/code

I switched to Developer Mode, and deleted the below files.

rm -rf generated/metadata/* 
rm -rf pub/static/_cache/* 
rm -rf pub/static/frontend/*
rm -rf generated/code/* 
rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf var/view_preprocessed/*

never delete pub/static/.htaccess. putting star *at the end does not delete .htaccess file in the folder.

you may also need to run setup di compile to optimize and regenerate magento2 file system.

bin/magento setup:di:compile
bin/magento indexer:reindex

OTHER TIPS

I got this exact same error when i was working on a site that was remotely hosted but i had the mounted on my machine using sshfs. When i tried to do this locally i got your error. When i logged into the remote serve through ssh i was able to run setup:upgrade just fine. So this points to issues with your connection to MySQL.

As your set up is most likely different then what i'm doing, i think the issue is running a local server that is using a different version of pph or MySQL then what is running in your terminal.

Take a look here and see if this clears up the issue for you:

http://devdocs.magento.com/guides/v2.0/install-gde/trouble/php/tshoot_phpini.html

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top