# Error when setup database

**URL:** <https://forums.jasonloong.com/t/error-when-setup-database/25>\
**Category:** Website Posts\
**Tags:** tutorials\
**Created:** [April 25, 2020, 5:16pm UTC](https://forums.jasonloong.com/t/error-when-setup-database/25 "2020-04-25T17:16:12Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![fred](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/fred/32/16_2.png) [@fred](https://forums.jasonloong.com/u/fred)\
**Post date:** [April 25, 2020, 5:16pm UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/1 "2020-04-25T17:16:12Z")

</div>

Hi there!

I’ve been following this great tutorial but unfortunately, it fails in the end when trying to setup the librenms database. Don’t quite know what to do at this stage ☹

root@nas:/volume1/docker/librenms# docker exec librenms setup\_database

In Connection.php line 664:

SQLSTATE[HY000] [2002] Connection timed out (SQL: select \* from information  
\_schema.tables where table\_schema = librenms and table\_name = migrations an  
d table\_type = ‘BASE TABLE’)

In PDOConnection.php line 31:

SQLSTATE[HY000] [2002] Connection timed out

In PDOConnection.php line 27:

SQLSTATE[HY000] [2002] Connection timed out

---

<div class="post-metadata">

**Author:** ![jasonloong](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/jasonloong/32/8_2.png) [@jasonloong](https://forums.jasonloong.com/u/jasonloong)\
**Post date:** [April 25, 2020, 5:51pm UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/2 "2020-04-25T17:51:12Z")

</div>

Hi Fred and welcome to the forums

Thank you for taking your time to post this

Never seen this error before

Could you post me your MariaDB and LibreNMS docker run code? (You can mask out the passwords etc)

I am assuming that the MariaDB database setup and admin privileges has been setup without problems? (The part where we login into the SQL CLI in the MariaDB container)

Still assuming things here, might be an error on linking the containers together. Eg: LibreNMS container unable to communicate with your MariaDB container, thus giving the timeout error

---

<div class="post-metadata">

**Author:** ![fred](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/fred/32/16_2.png) [@fred](https://forums.jasonloong.com/u/fred)\
**Post date:** [April 25, 2020, 9:49pm UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/3 "2020-04-25T21:49:27Z")

</div>

Thanks Jason! Here are the container definition:

## Mariadb

docker run -v /volume1/docker/mariadb:/var/lib/mysql -e MYSQL\_ALLOW\_EMPTY\_PASSWORD=yes -e TZ=America/Los\_Angeles --name mariadb -d mariadb:latest --sql-mode=‘’

I had to use MYSQL\_ALLOW\_EMPTY\_PASSWORD=yes since if I use MYSQL\_ROOT\_PASSWORD=random\_password when trying to connect to the DB with docker exec -it mariadb mysql -u root I get a Access denied for user ‘root’@‘localhost’ (using password: NO)

## librenms

docker run   
-p 8668:80   
-e DB\_HOST=db   
-e DB\_NAME=librenms   
-e DB\_USER=librenms   
-e DB\_PASS=random\_password   
-e APP\_KEY=base64:+kJkeYIsgMfab5qSYMg9csNP0OJQIc+mG+j0x48SDlo=   
-e BASE\_URL=[http://192.168.1.100:8668](http://192.168.1.100:8668)   
-e TZ=America/Los\_Angeles   
–link mariadb:db   
-v /volume1/docker/librenms/logs:/opt/librenms/logs   
-v /volume1/docker/librenms/rrd:/opt/librenms/rrd   
-v /volume1/docker/librenms/custom.config.php:/opt/librenms/conf.d/custom.config.php:ro   
–name librenms   
-d   
–restart always   
jarischaefer/docker-librenms:latest

After running the setup\_database and the timeout, when I look in the DB, I see that some tables had been created.

---

<div class="post-metadata">

**Author:** ![jasonloong](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/jasonloong/32/8_2.png) [@jasonloong](https://forums.jasonloong.com/u/jasonloong)\
**Post date:** [April 26, 2020, 1:51am UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/4 "2020-04-26T01:51:13Z")

</div>

Thank you for the docker run commands

> [@fred](#):
>
> After running the setup\_database and the timeout, when I look in the DB, I see that some tables had been created.

Hm…! Ok, so the host name works

> [@fred](#):
>
> I had to use MYSQL\_ALLOW\_EMPTY\_PASSWORD=yes since if I use MYSQL\_ROOT\_PASSWORD=random\_password when trying to connect to the DB with docker exec -it mariadb mysql -u root I get a Access denied for user ‘root’@‘localhost’ (using password: NO)

Yes this. You are my kinda second user confirming this, including me. Prior versions when I deployed the MariaDB, I had this problem too where I can’t login to the CLI even with the correct root password. So I tried to login the CLI without the “-p” option, which is to ask for your password, meanwhile checking whether root password has been set and it worked for some reason (only in Synology)

I tried to deploy a new MariaDB container on my end, here are the results, which is totally opposite of yours, where without setting -p logs me in

 ![Screenshot 2020-04-26 at 9.27.48 AM](https://forums.jasonloong.com/uploads/default/original/1X/a31b14bd148c71f152f33fc58a9d6be7e3e83493.png)

Note in screenshot:  
` mysql -u root`  
works rather than  
`mysql -u root -p`

Could you fast deploy from scratch to check on your end whether this is the same behaviour?

```auto
## stopping librenms and removing its files
docker stop librenms && docker rm librenms
rm -rvf /volume1/docker/librenms/* 
## same for mariadb, have to delete the local files
docker stop mariadb && docker rm mariadb
rm -rvf /volume1/docker/mariadb/*
## trying that mariadb run command again
docker run \
-v /volume1/docker/mariadb:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD="rooting" \
-e TZ=Asia/Singapore \
--name mariadb \
-d \
--restart always \
mariadb:latest \
--sql-mode=''
## after deploying
docker exec -it mariadb mysql -u root
# fingers crossed this works, if not, try the -p option
# enter "rooting" when asked for password
docker exec -it mariadb mysql -u root -p
# and if this works, you are the total opposite from me

```

Let me know again, if this behaviour is different on your end, I will need to update the tutorial with two methods of logging in the MySQL CLI 😅

---

<div class="post-metadata">

**Author:** ![jasonloong](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/jasonloong/32/8_2.png) [@jasonloong](https://forums.jasonloong.com/u/jasonloong)\
**Post date:** [April 26, 2020, 4:51am UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/5 "2020-04-26T04:51:27Z")

</div>

omg… it works now!

 ![Screenshot 2020-04-26 at 12.47.10 PM](https://forums.jasonloong.com/uploads/default/original/1X/74333d6339b2379ea727893c990bf252358c8686.png)

I left it running , now I could login with the -p option… 😱

Since I kinda got it to work with your scenario… meanwhile, continuing the rest of my tutorial steps…

will update again whether I run into the timeout issue

---

<div class="post-metadata">

**Author:** ![jasonloong](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/jasonloong/32/8_2.png) [@jasonloong](https://forums.jasonloong.com/u/jasonloong)\
**Post date:** [April 26, 2020, 5:18am UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/6 "2020-04-26T05:18:03Z")

</div>

Update: it works on my end

so far the only differences is that i am using a root password for MariaDB instead of no\_password, and I put in double quotes for the base64 key just in case for any special escape characters

```auto
docker run \
-p 8669:80 \
-e DB_HOST=db \
-e DB_NAME=librenms \
-e DB_USER=librenms \
-e DB_PASS=libre_password \
-e APP_KEY="base64:waWCoAjO4q8LnKH7mjVyyOqYTHxgzIFRyjdTOIGZoEw=" \
-e BASE_URL=http://MY.IP:8669 \
-e TZ=Asia/Singapore \
--link mariadb-test:db \
-v /volume1/docker/librenms-test/logs:/opt/librenms/logs \
-v /volume1/docker/librenms-test/rrd:/opt/librenms/rrd \
-v /volume1/docker/librenms-test/custom.config.php:/opt/librenms/conf.d/custom.config.php:ro \
--name librenms-test \
-d \
--restart always \
jarischaefer/docker-librenms:latest

```

```auto
docker exec librenms-test setup_database

```

```auto
docker exec librenms-test create_admin

```

 ![Screenshot 2020-04-26 at 1.09.02 PM](https://forums.jasonloong.com/uploads/default/original/1X/63bafc8c31dc7946ff936a1703224fa4d62b4159.png)

Mock adding of the Syno host device works as well

 ![Screenshot 2020-04-26 at 1.07.38 PM](https://forums.jasonloong.com/uploads/default/original/1X/fb4f7b93698025f6eb5f79f8ffac33f19d4c7763.png)

As for timeout issues… it seems like you are able to create some initial tables, but it stops in the end, the only factor that I could think of is load performance/issues.

Try stopping some of your existing containers when executing the creation of database in LibreNMS, if you are running other containers

My load in Syno Docker UI:

 ![Screenshot 2020-04-26 at 1.11.24 PM](https://forums.jasonloong.com/uploads/default/original/1X/6a689175d90e484e584294d6d3ee38a38fc71136.png)

Let’s start from scratch

- **clear all the current mariadb and librenms persistent local files and folders**
- create new folders etc
- run the mariaDB container  
**+ this time round, we restart the mariaDB container after you have created it**
- docker restart mariadb
- after a restart of mariadb, confirm that mysql -u root -p works with the root password you defined
- setup the mariadb privileges as written in tutorial
- you don’t have to generate a new key, just use the same key generated previously
- try your initial librenms docker run container command again
- populate database with setup\_database (fingers crossed)
- create admin

---

<div class="post-metadata">

**Author:** ![fred](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/fred/32/16_2.png) [@fred](https://forums.jasonloong.com/u/fred)\
**Post date:** [April 26, 2020, 7:19am UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/7 "2020-04-26T07:19:08Z")

</div>

Went through all the steps with a clean config, no containers. Same issue. I’m running DSM 6.2.2-24922 Update 4 on a DS218+ if that matters. Interestingly enough, docker exec -it mariadb mysql -u root worked and I was able to create the librenms DB via the CLI. Then I ran into the time out issue during the setup\_database script. But then I tried again docker exec -it mariadb mysql -u root and got ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO) ??!! This is weird. I can’t even access the CLI with docker exec -it mariadb mysql -u root -p  
Enter password:  
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)

I don’t know where that leave me. I don’t have any load on the NAS.

---

<div class="post-metadata">

**Author:** ![fred](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/fred/32/16_2.png) [@fred](https://forums.jasonloong.com/u/fred)\
**Post date:** [April 26, 2020, 7:30am UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/8 "2020-04-26T07:30:31Z")

</div>

I even tried to delete the docker package, reinstalled it and went through all the steps. Same problem. Very weird. ☹

---

<div class="post-metadata">

**Author:** ![jasonloong](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/jasonloong/32/8_2.png) [@jasonloong](https://forums.jasonloong.com/u/jasonloong)\
**Post date:** [April 26, 2020, 10:41am UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/9 "2020-04-26T10:41:03Z")

</div>

Thank you for the updates

Ok, can confirm this mysql -u root with/without -p problem with you then since it happened to you too… but I don’t understand how come you can’t login at a later stage -\_- this is just weird

If you have the time, maybe you could try deploying an older version of librenms? Just to see whether it’s only applicable to this version or all versions of LibreNMS

I would try v1.62 or even v1.6

You would substitute the latest tag with eg:  
`docker pull jarischaefer/docker-librenms:1.62`

Just replace `latest` with the version number

If this fails, try an older MariaDB container instead of the latest  
`docker pull mariadb:10.5`

I would love to help you but I can’t reproduce your timeout on my end … so I can’t tell which container’s the problem 😧

---

<div class="post-metadata">

**Author:** ![fred](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/fred/32/16_2.png) [@fred](https://forums.jasonloong.com/u/fred)\
**Post date:** [April 27, 2020, 5:27pm UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/10 "2020-04-27T17:27:17Z")

</div>

Tried with a bunch of older version. Similar problem … Really weird! Thank you for all your help! I will try to troubleshoot on my end. Probably something specific to my environment. It’s docker so don’t know where it could come from … Thank you again!

---

<div class="post-metadata">

**Author:** ![jasonloong](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/jasonloong/32/8_2.png) [@jasonloong](https://forums.jasonloong.com/u/jasonloong)\
**Post date:** [April 27, 2020, 11:24pm UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/11 "2020-04-27T23:24:16Z")

</div>

Thanks for the update Fred and you are welcome!

I hope things works out on your end

If you are still keen on getting LibreNMS to work, there’s the official Docker LibreNMS container to deploy too, though lots of side containers to load like the rrdcache, memcached etc

And since it’s official, you can reach out to the LibreNMS community for support

The steps are similar, for so many containers, using docker-compose might be a good idea.

Same tip applies: set a fixed image instead of latest for MariaDB

If you do a docker-compose pull (update all images), your database will run the latest version which might introduce problems during upgrades

Good luck!

---

<div class="post-metadata">

**Author:** ![fred](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/fred/32/16_2.png) [@fred](https://forums.jasonloong.com/u/fred)\
**Post date:** [June 16, 2020, 8:51pm UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/12 "2020-06-16T20:51:30Z")

</div>

Hey Jason! I FINALLY found what was the problem with my problem. Seems like the synology firewall was preventing something in the setup\_database scripts. I added a new entry to firewall rules: All, All, 172.18.0.0/255.255.0.0 and the script is able to run.

Phew. 😃

Fred

---

<div class="post-metadata">

**Author:** ![jasonloong](https://forums.jasonloong.com/user_avatar/forums.jasonloong.com/jasonloong/32/8_2.png) [@jasonloong](https://forums.jasonloong.com/u/jasonloong)\
**Post date:** [June 17, 2020, 12:01am UTC](https://forums.jasonloong.com/t/error-when-setup-database/25/13 "2020-06-17T00:01:06Z")

</div>

Omg! Firewall! 🤪😂

Thank you for the update! 🎉

This should help other users if they encounter similar problems

> [@fred](#):
>
> I added a new entry to firewall rules: All, All, 172.18.0.0/255.255.0.0
