Skip to content

Conversation

@rnorth
Copy link
Member

@rnorth rnorth commented May 9, 2020

Currently only a test to demonstrate #2627


Connection connection = DriverManager.getConnection(db.getJdbcUrl(), "root", "test");
connection.createStatement().execute("SELECT 1");
connection.createStatement().execute("set sql_log_bin=0");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used mysql/mysql-server:5.7.30 and this fails for me due to Access denied for user 'root'@'172.17.0.1'.

It looks like .withEnv("MYSQL_ROOT_HOST", "%")will also be needed.

ChristopheDuong added a commit to airbytehq/airbyte that referenced this pull request Mar 22, 2021
ChristopheDuong added a commit to airbytehq/airbyte that referenced this pull request Mar 23, 2021
…CI (#2531)

* Harmonize /test and /publish commands on github

* Make normalization build on clean system without PyICU

see https://getdbt.slack.com/archives/C50NEBJGG/p1615803416053800?thread_ts=1615511262.026400&cid=C50NEBJGG

* Follow example from testcontainers/testcontainers-java#2689 to modify MySQL container as root

* Add docs on new syntax for /test
@rnorth
Copy link
Member Author

rnorth commented Apr 11, 2021

I think this is fixed by #3953, aside from the mysql/mysql-server case. I'll rebase this PR on top of #3953 and update.

@rnorth rnorth self-assigned this Apr 12, 2021
@joaocanaverde
Copy link

@rnorth @ysb33r I've tried this:

try (
            MySQLContainer<?> db = new MySQLContainer<>("mysql:5.7.36")
                .withUsername("test")
                .withPassword("test")
                .withEnv("MYSQL_ROOT_PASSWORD", "test")
                .withEnv("MYSQL_ROOT_HOST", "%")
        ) {
            db.start();

            Connection connection = DriverManager.getConnection(db.getJdbcUrl(), "root", "test");
            
            connection.createStatement().execute("SELECT 1");
            connection.createStatement().execute("set sql_log_bin=0");
        }

And I keep getting:

Access denied for user 'root'@'172.17.0.1' (using password: YES)

Using the latest version:

<dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>mysql</artifactId>
            <version>1.16.2</version>
            <scope>test</scope>
        </dependency>

Are there any other workarounds or anything I might be missing? Thanks in advance!

@ysb33r
Copy link

ysb33r commented Oct 25, 2021

@rnorth @ysb33r I've tried this:

try (
            MySQLContainer<?> db = new MySQLContainer<>("mysql:5.7.36")
                .withUsername("test")
                .withPassword("test")
                .withEnv("MYSQL_ROOT_PASSWORD", "test")
                .withEnv("MYSQL_ROOT_HOST", "%")
        ) {
            db.start();

            Connection connection = DriverManager.getConnection(db.getJdbcUrl(), "root", "test");
            
            connection.createStatement().execute("SELECT 1");
            connection.createStatement().execute("set sql_log_bin=0");
        }

And I keep getting:

Access denied for user 'root'@'172.17.0.1' (using password: YES)

Using the latest version:

<dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>mysql</artifactId>
            <version>1.16.2</version>
            <scope>test</scope>
        </dependency>

Are there any other workarounds or anything I might be missing? Thanks in advance!

I don't know. I set up the database in the same way that you've done in the example and it works for me.

@rnorth
Copy link
Member Author

rnorth commented Jul 14, 2025

I think for the sake of tidiness I should close this now.

@rnorth rnorth closed this Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants