I have installed magento2 on my ubuntu system. Its worked fine. Then i have created a simple module in magento2. After that i am getting the following error

a:4:{i:0;s:66:"Setup version for module 'Sample_CustomControllers' is not specified";i:1;s:3170:"#0 /opt/lampp/htdocs/Magento2/vendor/magento/framework/Module/DbVersionInfo.php(56): Magento\Framework\Module\DbVersionInfo->isModuleVersionEqual('Sample_CustomCont...', false)
#1 /opt/lampp/htdocs/Magento2/vendor/magento/framework/Module/DbVersionInfo.php(79): Magento\Framework\Module\DbVersionInfo->isSchemaUpToDate('Sample_CustomCont...')
#2 /opt/lampp/htdocs/Magento2/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(55): Magento\Framework\Module\DbVersionInfo->getDbVersionErrors()
#3 [internal function]: Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#4 /opt/lampp/htdocs/Magento2/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#5 /opt/lampp/htdocs/Magento2/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#6 /opt/lampp/htdocs/Magento2/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(68): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#7 [internal function]: Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#8 /opt/lampp/htdocs/Magento2/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#9 /opt/lampp/htdocs/Magento2/vendor/magento/framework/Interception/Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#10 /opt/lampp/htdocs/Magento2/vendor/magento/module-page-cache/Model/App/FrontController/VarnishPlugin.php(55): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#11 [internal function]: Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#12 /opt/lampp/htdocs/Magento2/vendor/magento/framework/Interception/Interceptor.php(141): call_user_func_array(Array, Array)
#13 /opt/lampp/htdocs/Magento2/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#14 /opt/lampp/htdocs/Magento2/vendor/magento/framework/App/Http.php(115): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#15 /opt/lampp/htdocs/Magento2/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#16 /opt/lampp/htdocs/Magento2/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#17 {main}";s:3:"url";s:10:"/Magento2/";s:11:"script_name";s:19:"/Magento2/index.php";}

I have specified the setup version and all in the modules etc/module.xml file. When i searched this error i got a link in that they are telling to run the following commands

php -f bin/magento module:enable --clear-static-content Module_Name
php -f bin/magento setup:upgrade

But when i tried to run the second command i am getting another error

[Zend_Db_Adapter_Exception] SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 

[PDOException] SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.