zonkyio / embedded-database-spring-test

A library for creating isolated embedded databases for Spring-powered integration tests.
Apache License 2.0
412 stars 37 forks source link

How to set or find out user & password for running DB ? #274

Closed skarpushin closed 4 months ago

skarpushin commented 4 months ago

Hi!

During tests I observe weird behavior and I need to troubleshoot it. I don't know where the issue is - with my test or with my code. And it would be most convenient for me to open connection to DB using i.e. DBeaver so I can conveniently query data.

But I cannot find credentials that I can use to connect to the database. I'm using MariaDB.

How do I set or find out credentials for connecting to DB?

I've attempted to add bean and set password, but that didn't help

  @Bean
  public MariaDBContainerCustomizer mariaDBContainerCustomizer() {
    return container -> container.withEnv("MYSQL_ROOT_PASSWORD", "pwd");
  }
tomix26 commented 4 months ago

Hi @skarpushin, there should be a line in the log containing the jdbc string, including name and password. You can find more information about it here: https://github.com/zonkyio/embedded-database-spring-test?tab=readme-ov-file#connecting-to-the-embedded-database

skarpushin commented 4 months ago

Thank you! Line looked a bit differently than in the example provided, but I found it:

[mariadb:10.4] - Trying to create JDBC connection using org.mariadb.jdbc.Driver to jdbc:mariadb://localhost:56545/test with properties: {password=docker, user=test}