# Logstash mysql input credentials error

**URL:** https://discuss.elastic.co/t/logstash-mysql-input-credentials-error/105588
**Category:** Logstash
**Created:** [October 27, 2017, 3:10pm UTC](https://discuss.elastic.co/t/logstash-mysql-input-credentials-error/105588 "2017-10-27T15:10:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Tim\_Rourke](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim_rourke/32/23505_2.png) [@Tim\_Rourke](https://discuss.elastic.co/u/Tim_Rourke)
#### Post date: [October 27, 2017, 3:10pm UTC](https://discuss.elastic.co/t/logstash-mysql-input-credentials-error/105588/1 "2017-10-27T15:10:26Z")

</div>

Hello!

I'm trying to migrate some MySQL data from my local dev Vagrant box into Elasticsearch using the jdbc MySQL connector, and I'm running into a MySQL credentials problem. I'm not sure if the problem is the .conf file, or what.

Here's my config file:

```auto
input {
  jdbc {
    jdbc_driver_library => "/elasticsearch/mysql-connector-java-5.1.44/mysql-connector-java-5.1.44-bin.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/my-db-name-here?user=root&useSSL=false"
    jdbc_user => "mysql"
    statement => "select * from my_table limit 1"
  }
}
output {
    elasticsearch {
        index => "contacts"
        document_type => "contact"
        document_id => "%{uid}"
        hosts => "127.0.0.1"
    }
}

```

I've tried this with jdbc\_user set to "mysql" and to "root", both to no avail. MySQL is set up without a password for the root user, and I can log in using the MySQL CLI by issuing the command `mysql -u root -D my-db-name-here` without any trouble. Any thoughts?

This is the specific error message I am seeing:

```auto
  Error: Java::JavaSql::SQLException: Access denied for user 'root'@'localhost'
[ERROR] 2017-10-27 15:01:43.138 [[main]<jdbc] jdbc - Unable to connect to database. Tried 1 times {:error_message=>"Java::JavaSql::SQLException: Access denied for user 'root'@'localhost'"}

```

Thanks!

---

<div class="post-metadata">

### Author: ![Tim\_Rourke](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim_rourke/32/23505_2.png) [@Tim\_Rourke](https://discuss.elastic.co/u/Tim_Rourke)
#### Post date: [October 27, 2017, 3:45pm UTC](https://discuss.elastic.co/t/logstash-mysql-input-credentials-error/105588/2 "2017-10-27T15:45:53Z")

</div>

I should also note here that I have noticed that jdbc doesn't pick up the value I supply to `jdbc_user` at all - it only tries logging in as `root` if I include the username in the connection string as seen above. That seems incorrect?

---

<div class="post-metadata">

### Author: ![Tim\_Rourke](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim_rourke/32/23505_2.png) [@Tim\_Rourke](https://discuss.elastic.co/u/Tim_Rourke)
#### Post date: [October 27, 2017, 4:10pm UTC](https://discuss.elastic.co/t/logstash-mysql-input-credentials-error/105588/3 "2017-10-27T16:10:02Z")

</div>

Hah! I figured it out. The problem was that my MySQL user had no password. Creating a new user and providing it a password, granting it appropriate privileges in MySQL, and updating my logstash conf file fixed the issue.

---

<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 24, 2017, 4:10pm UTC](https://discuss.elastic.co/t/logstash-mysql-input-credentials-error/105588/4 "2017-11-24T16:10:11Z")

</div>

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