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

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
alfredlaggner
Posts: 29
Joined: 12 Oct 2016, 03:18

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

Post by alfredlaggner » 19 Nov 2016, 19:46

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

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

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

Post by aimeos » 20 Nov 2016, 15:37

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

alfredlaggner
Posts: 29
Joined: 12 Oct 2016, 03:18

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

Post by alfredlaggner » 20 Nov 2016, 17:11

It helped! Thank you.

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

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

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

Post by aimeos » 21 Nov 2016, 11:50

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply