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
--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
).
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.