[setup] Help connecting to a mysql database


Unless I didn’t read carefully the (well-written) documentation, I didn’t find a way to specifiy the mysql port, which I presume default to 3306 ?
Synology MariaDB 10 uses port 3307, and I would like to host my DB on it.

Could you add a variable to customize it ? Something like : VIKUNJA_DATABASE_PORT

Thanks :slight_smile:

You can include the port in the host: Config options | Vikunja :slightly_smiling_face:

Edit: You should be able to set it that way but I haven’t tested it.

I haven’t been able to make it adding :3307 after the hostname/IP of the host in the config options.
Yet, I only wanted to get a glimpse of your software, so sqlite will fit for this purpose in a first time. :slight_smile:

Hence, I think you could add an env var allowing to customize mysql port, as you did for redis config options.

Interesting, I was able to run this with mysql on a different port. How are you hosting it, native or docker?

I’m using Docker install method, here is my docker-compose.yml file :

version: '2.1'

      image: vikunja/api
      container_name: vikunja-api
         - net-vikunja
         - PUID=1000
         - PGID=1000
         - "VIKUNJA_DATABASE_HOST=nas.ndd.tld:3307"
         - VIKUNJA_DATABASE=vikunja
         - VIKUNJA_DATABASE_TYPE=mysql
         - VIKUNJA_DATABASE_USER=vikunja
         - VIKUNJA_SERVICE_TIMEZONE=Europe/Brussels
         - /opt/vikunja/vikunja.env
         - files:/app/vikunja/files
         - "com.centurylinklabs.watchtower.enable=true"
      restart: unless-stopped

      image: vikunja/frontend
      container_name: vikunja-fe
         - net-vikunja
         - net-proxy
         - "com.centurylinklabs.watchtower.enable=true"
      restart: unless-stopped




      external: true

      external: true

env_file contains database password for user ‘vikunja’ and smtp credentials.
As I was suspecting an eventual mistake around the quotes for VIKUNJA_DATABASE_HOST, I downloaded a config.yml.sample file and edited like this :

  # Database type to use. Supported types are mysql, postgres and sqlite.
  type: "mysql"
  # Database user which is used to connect to the database.
  user: "vikunja"
  # Database password
  password: "REDACTED"
  # Databse host
  host: "nas.ndd.tld:3307"
  # Databse to use
  database: "vikunja"

In both cases, except the log entry concerning the config file, I got below errors in stdout :

2021/05/18 10:43:21 Config File "config" Not Found in "[/app/vikunja /etc/vikunja /app/vikunja/.config/vikunja]",
2021/05/18 10:43:21 Using default config.,
2021-05-18T10:43:21.036671283Z: CRITICAL	▶ migration/Migrate 003 Migration failed: Error 1046: No database selected

Does the vikunja database exist in your mysql instance? The error message seems to indicate it is not as the “No database selected” error comes from the database. This means the vikunja api container is able to reach it - the configuration with the port in the host works.

So I tried to enter a wrong password in the env_file, and I got an access denied, so indeed it seems that MySQL can be reached, so as you are saying adding the port works. :slight_smile:
But, when I create the user “vikunja” with phpMyAdmin and give him privileges on “vikunja” database, I still get the “No database selected” error.
Could it be problems with special characters ? I don’t find any way to reduce mysql password enforcement rules, it seems hardcoded :confused:
Must say that I have some other docker containers using MySQL without any problem using the same methodology, that’s not my first attempt.

Thanks :slight_smile:

Does that mean you get the error in phpmyadmin? Does it work if you create a new user and database?

I’ve just noticed another thing: In your docker-compose config you specified the database as VIKUNJA_DATABASE=vikunja but that should be VIKUNJA_DATABASE_DATABASE=vikunja. Does it work with that?
Still, that doesn’t explain why it did not work with the config file.

1 Like

I feel stupid, you’re obviously right, it’s okay now :slight_smile:
I probably made another error in the config file. Now I have to deal with the reverse proxy, but that’s another subject :wink:
Thanks a lot for your support !

1 Like

Glad you figured it out!