Logstash mysql input credentials error

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:

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:

  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!

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?

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.

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