Why we have 2 database sections in the ENV file for docker


I already have mysql running in a separate container locally. I created a new database name invoiceninja in it and then setup the env file as:

# DB connection

I can see another section in the env file:


what’s it for? I think it should just use the existing database???


I’ve searched the codebase, the MYSQL_ params seem to be used for the automated tests.



thanks but is this something I must setup? I thought it just needs a database and once you’ve supplied the database connection details, it should create it’s own tables etc.?

I don’t think you need to provide those values.

ok why am I getting the following error:

SQLSTATE[HY000] [1045] Access denied for user 'ninja'@'' (using pa
ssword: YES) (Connection: mysql, SQL: select table_name as `name`, (data_le
ngth + index_length) as `size`, table_comment as `comment`, engine as `engi
ne`, table_collation as `collation` from information_schema.tables where ta
ble_schema = 'invoiceninja' and table_type = 'BASE TABLE' order by table_na
In Connector.php line 65:
SQLSTATE[HY000] [1045] Access denied for user 'ninja'@'' (using pa
ssword: YES)

mysql database is not running at I have specified it to be running on a different IP i.e.

@david can you please advise?

I supplied the following environment variables:

-e APP_ENV='production' \
  -e APP_DEBUG=0 \
  -e APP_URL='http://ninja.dev' \
  -e APP_KEY='base64:my_key' \
  -e APP_CIPHER='AES-256-CBC' \
  -e DB_TYPE='mysql' \
  -e DB_STRICT='false' \
  -e DB_HOST='' \
  -e DB_DATABASE='ninja' \
  -e DB_USERNAME='ninja' \
  -e DB_PASSWORD='ninja' \
  -e REQUIRE_HTTPS='true' \
  -e TRUSTED_PROXIES='my proxy ip address here'

you’re sure you created ‘ninja’ user and password with permissions to the ninja db in your db container? sometimes people forget this


I can login using ninja, with password ninja and can see the database ninja. I even created a test table to make sure user ninja had appropriate permissions to create tables in this database.

I don’t understand why we have to supply mysql and database options twice in the env file.
Once you have the database connection details with username/password/database name then it should be enough to create any database tables within that database?

btw I tested with both mysql and without mysql details. still get the same error.

I never had to supply the DB details twice in .env, only once and I’ve installed invoiceninja a dozen times…
The access denied error is likely that you restricted the ninja db user to only localhost or only a specific IP, please recreate the user with allowing access from all so you can test the connection from invoiceninja