mirromutth / r2dbc-mysql

R2DBC MySQL Implementation
Apache License 2.0
656 stars 100 forks source link

Error connecting to mysql version 8.0.18 #91

Closed hero-zhanghao closed 4 years ago

hero-zhanghao commented 4 years ago

When I used r2dbc to connect to mysql, the following error occurred:

Caused by: io.r2dbc.spi.R2dbcPermissionDeniedException: Authentication type 'þmysql_native_password' not supported at dev.miku.r2dbc.mysql.authentication.MySqlAuthProvider.build(MySqlAuthProvider.java:53) at dev.miku.r2dbc.mysql.LoginFlow.changeAuth(LoginFlow.java:119) at dev.miku.r2dbc.mysql.LoginFlow.access$900(LoginFlow.java:55) at dev.miku.r2dbc.mysql.LoginFlow$State$3.lambda$handle$2(LoginFlow.java:326) at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:96) at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onNext(MonoFlatMapMany.java:242) at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:192) at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:192) at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:112) at reactor.core.publisher.FluxConcatArray$ConcatArraySubscriber.onNext(FluxConcatArray.java:176) at reactor.core.publisher.EmitterProcessor.drain(EmitterProcessor.java:426) at reactor.core.publisher.EmitterProcessor.onNext(EmitterProcessor.java:268) at reactor.core.publisher.LambdaSubscriber.onNext(LambdaSubscriber.java:160) at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:192) at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:112) at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:218) at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:351) at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:348) at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:89) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) at dev.miku.r2dbc.mysql.client.MessageDuplexCodec.channelRead(MessageDuplexCodec.java:96) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:326) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:300) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1478) at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1227) at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1274) at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:503) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:442) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:281) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1422) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:931) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:700) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:635) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:552) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514) at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834)

Looking at the error, it looks like the driver did not support the validation type of 8.*. Do I have a solution?

hero-zhanghao commented 4 years ago

Here is my configuration:

@Override
@Bean
public ConnectionFactory connectionFactory() {
    ConnectionFactoryOptions options = ConnectionFactoryOptions.builder()
            .option(DRIVER, "mysql")
            .option(HOST, dbProperties.getIpaddr())
            .option(USER, dbProperties.getDbuser())
            .option(PORT, dbProperties.getPort())  // optional, default 3306
            .option(PASSWORD, dbProperties.getPasswd()) // optional, default null, null means has no password
            .option(DATABASE, dbProperties.getDbname())
            .build();
    final ConnectionFactory connectionFactory = ConnectionFactories.get(options);
    ConnectionPoolConfiguration configuration = ConnectionPoolConfiguration.builder(connectionFactory)
            .maxCreateConnectionTime(Duration.ofMillis(dbProperties.getPool().getMaxWait()))
            .maxSize(dbProperties.getPool().getMaxActive())
            .initialSize(dbProperties.getPool().getInitialSize())
            .build();
    return new ConnectionPool(configuration);
}
mirromutth commented 4 years ago

Hi there, thanks for report.

Looks like this mysql server started with Native MySQL Password Authentication. It should be set by my.cnf or container configuration files. I will try to reproduce it lately. If this problem will block/impact your work, try use MySQL 8.x default authentication type: caching_sha2_password.

mirromutth commented 4 years ago

The cause is AuthChangeMessage.decode, it should skip a byte which is a generic header 0xFE of authentication change messages.

Planning target version will be 0.8.1.RELEASE.

mirromutth commented 4 years ago

It has solved in #94 and published to 0.8.1.BUILD-SNAPSHOT, could you try again with that version please?

I have tested it on my local.

hero-zhanghao commented 4 years ago

The quick response was amazing, and after testing, the problem disappeared

venky1963 commented 4 years ago

I am not finding 0.8.1.BUILD-SNAPSHOT in Maven Central. I am new to R2DBC and trying to get a basic MySQL example to work.

hero-zhanghao commented 4 years ago

@venky1963 You can find this in repository below :

`

sonatype-snapshots SonaType Snapshots https://oss.sonatype.org/content/repositories/snapshots true

`

venky1963 commented 4 years ago

Thank you

Venky Kandaswamy 925-200-7124 Sent from my iPhone

On Jan 1, 2020, at 10:50 PM, hero-zhanghao notifications@github.com wrote:

 @venky1963 You can find this in repository below :

sonatype-snapshots SonaType Snapshots https://oss.sonatype.org/content/repositories/snapshots true

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.