J
J
J. Snow2017-02-09 12:26:04
MySQL
J. Snow, 2017-02-09 12:26:04

Java+MSQL: jdbc doesn't read options from my.ini/my.cnf?

Hey!
Registered user / pass in the file C: / my.ini

[client]
user=root
password=123456

I check - now you can connect to the database from the command line without entering a password.
But from a Java application - no:
SQLException: Access denied for user ''@'localhost' (using password: NO)

The code looks simple:
DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb")

Is there any way to make mysql-connector pull user/pass from my.ini/my.cnf ?
And are there any other ways to get around without explicitly specifying the password in jdbc?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Axian Ltd., 2017-02-09
@AxianLTD

MySQL does not store usernames/passwords in the config file. Everything lies in a special table in MySQL itself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question