Skip to content

[Bug]: Using the default user for Clickhouse will result in "Authentication Failed" #9939

@alexkops

Description

@alexkops

Module

Clickhouse

Testcontainers version

1.20.4

Using the latest Testcontainers version?

Yes

Host OS

Linux

Host Arch

x86

Docker version

Does not matter

What happened?

Because of this recent change in ClickHouse, the default testcontainer setup for Clickhouse won't work, because the default user is used:
ClickHouse/ClickHouse#75259

You will see the test fail with an error like this:
Authentication failed: password is incorrect, or there is no user with such name.
ClickHouse/ClickHouse#75494

Relevant log output

com.clickhouse.client.ClickHouseException: Code: 194. DB::Exception: default: Authentication failed: password is incorrect, or there is no user with such name.

If you use ClickHouse Cloud, the password can be reset at https://clickhouse.cloud/
on the settings page for the corresponding service.

If you have installed ClickHouse and forgot password you can reset it in the configuration file.
The password for default user is typically located at /etc/clickhouse-server/users.d/default-password.xml
and deleting this file will reset the password.
See also /etc/clickhouse-server/users.xml on the server where ClickHouse is installed.

. (REQUIRED_PASSWORD) (version 25.1.3.23 (official build))

	at app//com.clickhouse.client.ClickHouseException.of(ClickHouseException.java:151)
	at app//com.clickhouse.client.AbstractClient.lambda$execute$0(AbstractClient.java:275)
	at java.base@21.0.5/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
	at java.base@21.0.5/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base@21.0.5/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base@21.0.5/java.lang.Thread.run(Thread.java:1583)
Caused by: java.io.IOException: Code: 194. DB::Exception: default: Authentication failed: password is incorrect, or there is no user with such name.

Additional Information

We set up the testcontainer like this

    companion object {
        private val CLICKHOUSE_IMAGE_NAME: DockerImageName = DockerImageName.parse("clickhouse/clickhouse-server")

        @Container
        var clickHouseContainer = ClickHouseContainer(CLICKHOUSE_IMAGE_NAME)

        @JvmStatic
        @DynamicPropertySource
        fun registerDynamicProperties(registry: DynamicPropertyRegistry) {
            registry.add("clickhouse.host") { clickHouseContainer.host }
            registry.add("clickhouse.port") { clickHouseContainer.getMappedPort(8123) }
            registry.add("clickhouse.username") { clickHouseContainer.username }
            registry.add("clickhouse.password") { clickHouseContainer.password }
            registry.add("clickhouse.enabled") { true }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions