I don't have permission to access librenms database but i have full privlieges

I get the error:
"MySQL Error: Could not select database: librenms. Access denied for user 'librenms'@'localhost' to database 'librenms'" <---- This is via ansible

However when i go into mysql using mysql -u root -p and run show grants for 'librenms'@'localhost';

I get shown that:

| Grants for [email protected]                                                                                   |
| GRANT USAGE ON *.* TO 'librenms'@'localhost' IDENTIFIED BY PASSWORD '*bunchofstuffhere' |
| GRANT ALL PRIVILEGES ON `*librenms`.* TO 'librenms'@'localhost'                                                 |

What am i missing here that’s breaking my access to librenms with my librenms account?

DB settings are stored in .env

I checked and the contents are:


DB_PASSWORD=pass-> an actual pass is here

NODE_ID=node_id -> an actual node_id is here

Is there something wrong here?

APP_KEY is missing, run php artisan key:generate

I got the error:
Could not select database: librenms. Access denied for user ‘libr
enms’@‘localhost’ to database ‘librenms’

Do you have an APP_KEY now though?

It just cancels out with that error in all red

does your password start with #?

If so you can either suround it in " or run ./daily.sh as the librenms user to fix it.

Nope my password starts with a letter


Also, you can comment out all DB_ options and run php artisan key:generate.

But I think something is wrong with your db credentials.

This is what i get as my output: from the php artisan key:generate

[2018-07-23 12:02:39] production.ERROR: LibreNMS\Exceptions\DatabaseConnectException: Could not select database: librenms. Access denied for user 'librenms'@'localhost' to database 'librenms' in /opt/librenms/includes/dbFacile.php:99
    Stack trace:
#0 /opt/librenms/app/Providers/AppServiceProvider.php(33): dbConnect('', 'librenms', 'mypass', 'librenms', '3306', NULL)
#1 [internal function]: App\Providers\AppServiceProvider->boot()
#2 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#3 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#4 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#5 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#6 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(788): Illuminate\Container\Container->call(Array)
#7 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(771): Illuminate\Foundation\Application->bootProvider(Object(App\Providers\AppServiceProvider))
#8 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation\{closure}(Object(App\Providers\AppServiceProvider), 13)
#9 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(772): array_walk(Array, Object(Closure))
#10 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\Foundation\Application->boot()
#11 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(208): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#12 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(267): Illuminate\Foundation\Application->bootstrapWith(Array)
#13 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(114): Illuminate\Foundation\Console\Kernel->bootstrap()
#14 /opt/librenms/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 {main}  

In dbFacile.php line 99:
  Could not select database: librenms. Access denied for user 'librenms'@'localhost' to database 'librenms'

aka your credentials are wrong (not sure how).

comment out all DB_ options and run php artisan key:generate.

Like my database pass and user dont match? How would I fix this when I did it through an ansible playbook with the same password for the user, database, and everything sql related?

EDIT: I commented everything out and still got the same error

Doesn’t have anything to do with .env then, your db credentials are just wrong. (possibly an issue with “localhost” as I mentioned above)

If you comment them out in .env it falls back to config.php

Ok. I’m also facing an issue that if I set the same stuff that I have setup in ansible manually (mysql permissions and such then everything works just fine), but the automation via ansible breaks it. Could this be due to that same issue or is ansible automation with mysql not allowing something to work with the permissions?


I did a test and remade the whole machine (vm) and tested with making no password for the user.

Then I ran ./validate.php and received this:

Component | Version
--------- | -------
LibreNMS  | 1.41-50-g8f4a041b8
DB Schema | ?
PHP       | 7.0.30-0+deb9u1
MySQL     | ?
RRDTool   | 1.6.0
SNMP      | NET-SNMP 5.7.3

[OK]    Composer Version: 1.6.5
[OK]    Dependencies up-to-date.
[FAIL]  Error connecting to your database. Access denied for user 'librenms'@'localhost' (using password: NO)
[WARN]  Could not check poller/discovery, db is not connected.