3

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.

  • Check the health of your mysql server. Try restart it and see what happens. – Paras Sood Feb 15 '17 at 17:04
  • Check your database connection string !! something is wrong or missing there !! also one more thing check your mysql server is it working or not ? issue is related to mysql and database configuration related – Manthan Dave Feb 15 '17 at 17:45
  • I know mysql server is working, i'm trying to check the path for mysql connection, one of the solutions i've been reading about talks about changing it in the bash profile – Alejandro Guzman Feb 15 '17 at 18:10
3

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 magento file system

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.