-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
MySQL: Fix problem of starting up mysql 5.7.33 version when user is root #3953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rnorth
merged 5 commits into
testcontainers:master
from
seveneves:imposible_to_start_mysql_5.7.33_with_root
Apr 11, 2021
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
34c2bc7
Fix problem of starting up mysql 5.7.33 version when user is root
d099862
Fix typo
32a7629
Add test that checks root account usage for mysql version 8 and 5
03151ea
Use empty string instead of null password
seveneves 8b76f3f
Add check that root account is used
seveneves File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
modules/mysql/src/test/java/org/testcontainers/containers/MySQLRootAccountTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package org.testcontainers.containers; | ||
|
|
||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
| import org.junit.runners.Parameterized; | ||
| import org.testcontainers.containers.output.Slf4jLogConsumer; | ||
|
|
||
| import java.sql.Connection; | ||
| import java.sql.DriverManager; | ||
| import java.sql.SQLException; | ||
|
|
||
| @Slf4j | ||
| @RunWith(Parameterized.class) | ||
| public class MySQLRootAccountTest { | ||
|
|
||
| @Parameterized.Parameters(name = "{0}") | ||
| public static String[] params() { | ||
| return new String[]{ | ||
| "mysql:8", | ||
| "mysql:5" | ||
| }; | ||
| } | ||
|
|
||
| @Parameterized.Parameter() | ||
| public String image; | ||
|
|
||
| @Test | ||
| public void testRootAccountUsageWithDefaultPassword() throws SQLException { | ||
| testWithDB(new MySQLContainer<>(image).withUsername("root")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testRootAccountUsageWithEmptyPassword() throws SQLException { | ||
| testWithDB(new MySQLContainer<>(image).withUsername("root").withPassword("")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testRootAccountUsageWithCustomPassword() throws SQLException { | ||
| testWithDB(new MySQLContainer<>(image).withUsername("root").withPassword("not-default")); | ||
| } | ||
|
|
||
| private void testWithDB(MySQLContainer<?> db) throws SQLException { | ||
| try { | ||
| db.withLogConsumer(new Slf4jLogConsumer(log)).start(); | ||
| Connection connection = DriverManager.getConnection(db.getJdbcUrl(), db.getUsername(), db.getPassword()); | ||
| connection.createStatement().execute("SELECT 1"); | ||
| connection.createStatement().execute("set sql_log_bin=0"); // requires root | ||
| } finally { | ||
| db.close(); | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.