# Configure JDBC input with SSL connection for MySQL

**URL:** <https://discuss.elastic.co/t/configure-jdbc-input-with-ssl-connection-for-mysql/103069>\
**Category:** Logstash\
**Created:** [October 6, 2017, 7:14pm UTC](https://discuss.elastic.co/t/configure-jdbc-input-with-ssl-connection-for-mysql/103069 "2017-10-06T19:14:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Devang\_Gaglani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/devang_gaglani/32/22844_2.png) [@Devang\_Gaglani](https://discuss.elastic.co/u/Devang_Gaglani)\
**Post date:** [October 6, 2017, 7:14pm UTC](https://discuss.elastic.co/t/configure-jdbc-input-with-ssl-connection-for-mysql/103069/1 "2017-10-06T19:14:22Z")

</div>

I want to connect to MySQL database for collecting logs in logstash. But database is having secured connection. How do I set SSL in JDBC input plugin of logstash for MySQL database?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 10, 2017, 9:06am UTC](https://discuss.elastic.co/t/configure-jdbc-input-with-ssl-connection-for-mysql/103069/2 "2017-10-10T09:06:54Z")

</div>

I'd expect this should to work the same way as with all other JDBC clients, i.e. you'll have to adjust the connection string (see e.g. [https://stackoverflow.com/a/34324275/414355](https://stackoverflow.com/a/34324275/414355)).

---

<div class="post-metadata">

**Author:** ![Devang\_Gaglani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/devang_gaglani/32/22844_2.png) [@Devang\_Gaglani](https://discuss.elastic.co/u/Devang_Gaglani)\
**Post date:** [October 10, 2017, 7:19pm UTC](https://discuss.elastic.co/t/configure-jdbc-input-with-ssl-connection-for-mysql/103069/3 "2017-10-10T19:19:17Z")

</div>

I tired this in config file:  
input{  
jdbc {  
jdbc\_connection\_string =\> "jdbc:mysql://10.112.112.43:3306/testDB?useSSL=true&verifyServerCertificate=false&requireSSL=true"  
jdbc\_user =\> "root"  
jdbc\_password =\> "root"  
jdbc\_validate\_connection =\> true  
jdbc\_driver\_library =\> "/usr/share/logstash/bin/mysql-connector-java-5.1.44/mysql-connector-java-5.1.44-bin.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
statement =\> "SELECT \* from master"  
}  
}

after executing  
bin/logstash -f bin/logstash-example.conf  
No error, but logstash not getting started. Output of command:  
WARNING: Could not find logstash.yml which is typically located in $LS\_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults  
Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console  
root@logstash:/usr/share/logstash#

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 10, 2017, 7:28pm UTC](https://discuss.elastic.co/t/configure-jdbc-input-with-ssl-connection-for-mysql/103069/4 "2017-10-10T19:28:31Z")

</div>

The jdbc input doesn't keep Logstash alive, i.e. it runs the query once and then Logstash shuts down. It's therefore totally possible that things are working but you're just not seeing the results. Do you have any outputs defined? Do you get more clues if you bump Logstash's loglevel?

---

<div class="post-metadata">

**Author:** ![Devang\_Gaglani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/devang_gaglani/32/22844_2.png) [@Devang\_Gaglani](https://discuss.elastic.co/u/Devang_Gaglani)\
**Post date:** [October 10, 2017, 9:21pm UTC](https://discuss.elastic.co/t/configure-jdbc-input-with-ssl-connection-for-mysql/103069/5 "2017-10-10T21:21:47Z")

</div>

Hi,  
Thanks for info! redirecting output to elasticsearch and then to Kibana.  
I am using database to get logs which are stored in database. I was hoping to keep it live so that an new record with logs can be fetched by logstash. Is there any way to do this?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 11, 2017, 5:13am UTC](https://discuss.elastic.co/t/configure-jdbc-input-with-ssl-connection-for-mysql/103069/6 "2017-10-11T05:13:48Z")

</div>

Yes, there's a built-in schedule feature to run the query at intervals. Use that together with the `sql_last_value` parameter to only pick up new or updated rows. See the documentation.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 8, 2017, 5:26am UTC](https://discuss.elastic.co/t/configure-jdbc-input-with-ssl-connection-for-mysql/103069/7 "2017-11-08T05:26:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
