protected EmbeddedMysql(final MysqldConfig config) { this.config = config; IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(config.getVersion()).build(); this.executable = new MysqldStarter(runtimeConfig).prepare(config); try { executable.start(); getClient(SCHEMA) .executeCommands( format( "CREATE USER '%s'@'%%' IDENTIFIED BY '%s';", config.getUsername(), config.getPassword())); } catch (IOException e) { throw new RuntimeException(e); } }
public synchronized void stop() { if (isRunning.getAndSet(false)) { executable.stop(); } }