What JDBC property corresponds to mysql command line's “--skip-secure-auth” option?

可紊 提交于 2019-12-21 22:55:29

问题


I have one legacy database which needs to be connected like this from command prompt

mysql --uUserName -hHostName -pPassword -P3307 -A Schema --skip-secure-auth

How do I specify the same in JDBC properties --skip-secure-auth

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://HostName:3307/Schema
jdbc.user=UserName
jdbc.password=Password
jdbc.maxConnections=5

回答1:


--skip-secure-auth allows the use of the old, pre-4.1 password hashing method. This obsolete authentication mechanism is handled by a plugin known as mysql_old_password.

According to the Connector/J manual, it is not disabled by default (read about the disabledAuthenticationPlugins option), so I suppose the default behaviour is to allow such connections (i.e. equivalent to mysql --skip-secure-auth).




回答2:


In case someone has still the same problem as OP of MySQL using older password hashing method, then the recommended practice is to change the passwords as pointed here.

If at the moment the above is not possible and you just want to make your JDBC connector connect to MySQL the old not so secure way, then way to do it in context.xml file is

authenticationPlugins="com.mysql.jdbc.authentication.MysqlOldPasswordPlugin"

Not sure what is the corresponding JDBC syntax.

Since mysql-connector-java-5.1.19 (latest one I have is 5.1.23) JAR, the default authentication is com.mysql.jdbc.authentication.MysqlNativePasswordPlugin, so you are basically changing the authentication mode from the default to older one through the above mentioned snippet.



来源:https://stackoverflow.com/questions/25443827/what-jdbc-property-corresponds-to-mysql-command-lines-skip-secure-auth-opti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!