You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "david radley (Jira)" <ji...@apache.org> on 2023/11/01 09:58:00 UTC

[jira] [Comment Edited] (FLINK-28433) Allow connection to mysql through mariadb driver

    [ https://issues.apache.org/jira/browse/FLINK-28433?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17781681#comment-17781681 ] 

david radley edited comment on FLINK-28433 at 11/1/23 9:57 AM:
---------------------------------------------------------------

hi [~bzhaoop] ,   

are you still looking at this?  It looks like there was an agreed pr, but then the JDBC connector got moved out of the core repository. The fix was not ported over.

I wondered if the pr is basically the same as mySQL apart from the prefix (they are supposed to be the same). If so I wonder if we could just change the mysql dialect library to accept mariadb url prefixes as well as mysql - or is more required? 

Change MySqlDialectFactory like this:

 
public boolean acceptsURL(String url) {
return url.startsWith("jdbc:mysql:") || url.startsWith("jdbc:mariadb:");
}
 
This change works for me with my limited testing.
 

 


was (Author: JIRAUSER300523):
hi [~bzhaoop] ,   

are you still looking at this? 

The reason MariaDB does not work is because of the jdbc url. Order Mariadb JDBC drivers would accept mysql, later ones require a query param permitMysqlScheme on the jdbc url, see  [https://mariadb.com/kb/en/about-mariadb-connector-j/|http://example.com](https://mariadb.com/kb/en/about-mariadb-connector-j/). 

 

The mysql dialect factory has 

 
MySqlDialectFactory implements JdbcDialectFactory {
@Override
public boolean acceptsURL(String url) {
return url.startsWith("jdbc:mysql:");
}

@Override
public JdbcDialect create() {
return new MySqlDialect();
}
}
 

If we change the accepts URL to: 

return url.startsWith("jdbc:mysql:") || url.startsWith("jdbc:mariadb:");

Then it works. Is this an acceptable change, with some associated documentation changes? If so, please assign me the issue and I will fix it. 

 

  

 

 

> Allow connection to mysql through mariadb driver
> ------------------------------------------------
>
>                 Key: FLINK-28433
>                 URL: https://issues.apache.org/jira/browse/FLINK-28433
>             Project: Flink
>          Issue Type: Improvement
>          Components: Connectors / JDBC
>            Reporter: PengLei
>            Assignee: bo zhao
>            Priority: Minor
>              Labels: pull-request-available, stale-assigned
>         Attachments: image-2022-07-07-09-29-06-834.png
>
>
> Flink connector support connection to mysql. But the url must be started with "jdbc:mysql". 
> Some user need to use mariadb dirver to connect to mysql. It can be achieved by setting the driver parameter in jdbcOptions. Unfortunately, the url verification fails.
>  
> as follows:
> !image-2022-07-07-09-29-06-834.png!
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)