Page 1 of 1

Database error message: Access denied for user 'root'@'local

Posted: 19 Nov 2016, 19:46
by alfredlaggner
Seemingly from one moment to the next I got this error message

Code: Select all

Exception in DBAL.php line 92:
Executing statement "SET NAMES 'utf8'" failed: An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)
in DBAL.php line 92
at DBAL->acquire('db') in Base.php line 63
at Base->createSearch() in Standard.php line 669
at Standard->createSearch() in Standard.php line 121
at Standard->bootstrap('default', '', '', false)
at call_user_func_array(array(object(Standard), 'bootstrap'), array('default', '', '', false)) in Base.php line 51
at Base->__call('bootstrap', array('default', '', '', false)) in Locale.php line 84
at Locale->getBackend(object(Standard), 'default') in Support.php line 61
at Support->checkGroup('2', array('admin', 'editor')) in AuthServiceProvider.php line 29
at AuthServiceProvider->App\Providers\{closure}(object(User), array('admin', 'editor')) in Gate.php line 265
at Gate->callAuthCallback(object(User), 'admin', array(array('admin', 'editor'))) in Gate.php line 243
at Gate->raw('admin', array(array('admin', 'editor'))) in Gate.php line 218
at Gate->authorize('admin', array(array('admin', 'editor'))) in AuthorizesRequests.php line 22
at JqadmController->authorize('admin', array(array('admin', 'editor'))) in JqadmController.php line 163
at JqadmController->searchAction('dashboard')
at call_user_func_array(array(object(JqadmController), 'searchAction'), array('resource' => 'dashboard')) in Controller.php line 55
at Controller->callAction('searchAction', array('resource' => 'dashboard')) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(JqadmController), 'searchAction') in Route.php line 189
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 642
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137

......


Since I could not find an error I decided to restore from the previous day - same result

then I decided to do a fresh database install and got a similar error at the command

Code: Select all

php artisan aimeos:setup --option=setup/default/demo:1
error message:

Code: Select all

 [Aimeos\MW\DB\Exception]
  Executing statement "SET NAMES 'utf8'" failed: An exception occured in driv
  er: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using
   password: NO)

Code: Select all

 [Aimeos\MW\DB\Exception]
  Executing statement "SET NAMES 'utf8'" failed: An exception occured in driv
  er: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using
   password: NO)
I read up on this issue on stackoverflow but I did not find an appearant solution. I need your expert help!
I don't want to mess with my database privileges since I have other databases running as well. I did some upgrades two days ago on my cloud server (digital ocean) when I attempted to upgrade Nginx to version 16. But the error happened yesterday.

Thank you.

Alfred

Re: Database error message: Access denied for user 'root'@'l

Posted: 20 Nov 2016, 15:37
by aimeos
Sometimes, the dotenv package makes problems. Please try to add your database credentials to the config/shop.php as well, so they are not used from your .env file.

Re: Database error message: Access denied for user 'root'@'l

Posted: 20 Nov 2016, 17:11
by alfredlaggner
It helped! Thank you.

Will you work on this issue? Isn't the database less secure now that the credentials are visible?

Re: Database error message: Access denied for user 'root'@'l

Posted: 21 Nov 2016, 11:50
by aimeos
There's nothing we can do as this is a problem of the dotenv package. According to the developer of the dotenv package it was never meant for production use.

And no, it's not less secure because
- PHP files are never sent as text to the client
- the files are usually not in the document root

To be honest, the probability that the .env files are a security risk is higher than for PHP files. Just place your Laravel application in a subdirectory of your document root and forget to deny access for the .env file. Then, everyone can read your credentials and passwords.