Web installer Build Database Error 2002 (HY000): Can't connect to server on 'localhost' (13)

I’m start a new Librenms on CentOS7 ngnix, I’m stuck with web install Build DB.

Here is the output of build DB:

Starting Update…

INFO Preparing database.

Creating migration table

1,059ms
DONE

INFO Loading stored database schemas.

database/schema/mysql-schema.dump

857ms
FAIL
The command “mysql --user=”${:LARAVEL_LOAD_USER}" --password=“${:LARAVEL_LOAD_PASSWORD}” --host=“${:LARAVEL_LOAD_HOST}” --port=“${:LARAVEL_LOAD_PORT}” --database=“${:LARAVEL_LOAD_DATABASE}” < “${:LARAVEL_LOAD_PATH}”" failed.

Exit Code: 1(General error)

Working directory: /opt/librenms/html

Output:

Error Output:

mysql: Deprecated program name. It will be removed in a future release, use ‘/usr/bin/mariadb’ instead
ERROR 2002 (HY000): Can’t connect to server on ‘localhost’ (13)

Error!

Here is the log in MariaDB status:

Aug 16 14:44:01 localhost.localdomain mariadbd[6890]: 2023-08-16 14:44:01 935 [Warning] Access denied for user ‘librenms@localho’@‘localhost’ (using password: YES)
Aug 16 14:44:01 localhost.localdomain mariadbd[6890]: 2023-08-16 14:44:01 936 [Warning] Access denied for user ‘librenms@localho’@‘localhost’ (using password: YES)

===================================================================
Here is my validate:

bash-4.2$ ./validate.php

Component Version
LibreNMS 23.7.0-74-g6e4d124 (2023-08-13T23:43:52+07:00)
DB Schema No Schema (0)
PHP 8.1.22
Python 3.6.8
Database MariaDB 11.0.3-MariaDB
RRDTool 1.4.8
SNMP 5.7.2
===========================================

[OK] Composer Version: 2.5.8
[OK] Dependencies up-to-date.

In Connection.php line 795:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.devices’ doesn’t exist (Connection: mysql, SQL: select exists(select * from devices) as exists)

In Connection.php line 416:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.devices’ doesn’t exist

bash-4.2$

Thank a lot for your help

Appears to be an issue with .env file contents.
is DB username and password correct in .env file ?

1 Like

yes, I did it

Here is my .env file:

DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=librenms
DB_USERNAME=librenms
DB_PASSWORD=********
DB_SOCKET=

I can login to MariaDB by acoount librenms and it password
I follow this link: RHEL / CentOS 7 - Nginx - LibreNMS Docs due to I have CentOS7 installed

During yum install I get error as below:

#Running setup.py install for psutil: finished with status ‘error’
#error: command ‘gcc’ failed with exit status 1

Log from Librenms:
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.services’ doesn’t exist (Connection: mysql, SQL: SELECT D.,S.,attrib_value FROM devices AS D INNER JOIN services AS S ON S.device_id = D.device_id AND D.disabled = 0 LEFT JOIN devices_attribs as A ON D.device_id = A.device_id AND A.attrib_type = “override_icmp_disable” ORDER by D.device_id DESC;) (Connection: dbFacile, SQL: SELECT D.,S.,attrib_value FROM devices AS D INNER JOIN services AS S ON S.device_id = D.device_id AND D.disabled = 0 LEFT JOIN devices_attribs as A ON D.device_id = A.device_id AND A.attrib_type = “override_icmp_disable” ORDER by D.device_id DESC;)#0 /opt/librenms/check-services.php(57): dbFetchRows()
#1 {main}
/opt/librenms/discovery.php new 2023-08-17 16:15:02 - 0 devices discovered in 0.005 secs

long back i had this error gcc failed on ubuntu
if i remember correctly, fix was to install python3-dev

for centos , i think yum install python3-devel

i dont have centos to test

1 Like

Thank a lot RR1
I can install python3 but not solve my problem
Log form Librenms:

Next Illuminate\Database\QueryException: SQLSTATE[HY000] [1045] Access denied for user ‘librenms’@‘localhost’ (using password: NO) (Connection: mysql, SQL: select * from config where (config_name = snmp.unescape) limit 1) in /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Connection.php:795
Stack trace:
#0 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Connection.php(755): Illuminate\Database\Connection->runQueryCallback()
#1 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Connection.php(424): Illuminate\Database\Connection->run()
#2 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2748): Illuminate\Database\Connection->select()
#3 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2736): Illuminate\Database\Query\Builder->runSelect()
#4 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3290): Illuminate\Database\Query\Builder->Illuminate\Database\Query{closure}()
#5 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2737): Illuminate\Database\Query\Builder->onceWithColumns()
#6 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(720): Illuminate\Database\Query\Builder->get()
#7 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(704): Illuminate\Database\Eloquent\Builder->getModels()
#8 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(296): Illuminate\Database\Eloquent\Builder->get()
#9 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(549): Illuminate\Database\Eloquent\Builder->first()
#10 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(583): Illuminate\Database\Eloquent\Builder->firstOrNew()
#11 /opt/librenms/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(23): Illuminate\Database\Eloquent\Builder->updateOrCreate()
#12 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2333): Illuminate\Database\Eloquent\Model->forwardCallTo()
#13 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2345): Illuminate\Database\Eloquent\Model->__call()
#14 /opt/librenms/LibreNMS/Config.php(262): Illuminate\Database\Eloquent\Model::__callStatic()
#15 /opt/librenms/LibreNMS/Config.php(474): LibreNMS\Config::persist()
#16 /opt/librenms/LibreNMS/Config.php(61): LibreNMS\Config::processConfig()
#17 /opt/librenms/app/Providers/ConfigServiceProvider.php(27): LibreNMS\Config::load()
#18 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\Providers\ConfigServiceProvider->boot()
#19 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
#20 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#21 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()
#22 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\Container\BoundMethod::call()
#23 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1006): Illuminate\Container\Container->call()
#24 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(987): Illuminate\Foundation\Application->bootProvider()
#25 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation{closure}()
#26 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(988): array_walk()
#27 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\Foundation\Application->boot()
#28 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(261): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap()
#29 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(447): Illuminate\Foundation\Application->bootstrapWith()
#30 /opt/librenms/LibreNMS/Util/Laravel.php(44): Illuminate\Foundation\Console\Kernel->bootstrap()
#31 /opt/librenms/includes/init.php(90): LibreNMS\Util\Laravel::bootCli()
#32 /opt/librenms/alerts.php(34): require(‘…’)
#33 {main}

now username is correct, but password say NO, it supposed to be yes.
did u change any thing in .env again ?

Yes, for test DB connection I use the password as very similar “password” . I have MariaDB 11.0.3
Here is my .env file

DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=librenms
DB_USERNAME=librenms
DB_PASSWORD=********

it work after few hours… I don’t know why, but it working now…

Here is working logs form Libre

/opt/librenms/discovery.php new 2023-08-18 00:20:02 - 0 devices discovered in 0.005 secs
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.services’ doesn’t exist (Connection: mysql, SQL: SELECT D.,S.,attrib_value FROM devices AS D INNER JOIN services AS S ON S.device_id = D.device_id AND D.disabled = 0 LEFT JOIN devices_attribs as A ON D.device_id = A.device_id AND A.attrib_type = “override_icmp_disable” ORDER by D.device_id DESC;) (Connection: dbFacile, SQL: SELECT D.,S.,attrib_value FROM devices AS D INNER JOIN services AS S ON S.device_id = D.device_id AND D.disabled = 0 LEFT JOIN devices_attribs as A ON D.device_id = A.device_id AND A.attrib_type = “override_icmp_disable” ORDER by D.device_id DESC;)#0 /opt/librenms/check-services.php(57): dbFetchRows()
#1 {main}
/opt/librenms/discovery.php new 2023-08-18 00:25:02 - 0 devices discovered in 0.004 secs
/opt/librenms/discovery.php new 2023-08-18 00:30:02 - 0 devices discovered in 0.004 secs

thnak you RR1

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.