[MDEV-12961] Client conf files Created: 2017-05-31  Updated: 2018-03-21

Status: Stalled
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.2.6
Fix Version/s: 10.2

Type: Bug Priority: Major
Reporter: Olaf van der Spek Assignee: Georg Richter
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates CONC-317 Whitespace around assignment token no... Closed
Relates
relates to MDEV-12965 libmariadb reads only the first found... Closed

 Description   

I'm using libmariadb 2.3.2 from vcpkg on Windows 10.

What conf files is this supposed to read? I can't find the docs.
MySQL says it reads %APPDATA%\MySQL\.mylogin.cnf but I can't get it to work.

mysql_init(&m_handle);
mysql_options(&m_handle, MYSQL_READ_DEFAULT_GROUP, "");
mysql_real_connect(&m_handle, "", "", NULL, database.c_str(), 0, NULL, 0));

C:\Users\Olaf\AppData\Roaming\MySQL\.mylogin.cnf

[client]
host = debian
user = root

Error: Can't connect to MySQL server on 'localhost' (0)
After I hard-code the host: Access denied for user 'Olaf'@'192.168.157.1' (using password: NO)



 Comments   
Comment by Sergei Golubchik [ 2017-05-31 ]

This is one of the cases where MySQL documentation doesn't apply directly to MariaDB. No version of MariaDB ever read .mylogin.cnf

On Windows libmariadb reads my.cnf and my.ini in C:\, current directory, %WINDOWS% and %HOMEPATH%.

Comment by Olaf van der Spek [ 2017-05-31 ]

Thx! Where do I find the docs on this? And in what file do I find the code?
I've now moved the file to "C:\Users\Olaf\my.cnf" but it still seems to be ignored.

Comment by Sergei Golubchik [ 2017-05-31 ]

https://mariadb.com/kb/en/mariadb/configuring-mariadb-with-mycnf/ — it's about the server, but the client library is using similar rules.

https://github.com/MariaDB/mariadb-connector-c/blob/master/libmariadb/ma_default.c

Comment by Olaf van der Spek [ 2017-05-31 ]

1. I can't find HOMEPATH @ https://mariadb.com/kb/en/mariadb/configuring-mariadb-with-mycnf/
2. HOMEPATH=\Users\Olaf so I think you need to combine it with HOMEDRIVE.
3. Still doesn't work.

4.
> MariaDB will look in all of the above locations, in order, even if has already found a my.cnf file, and it's possible for more than one my.cnf file to exist.

_mariadb_get_default_file seems to return the first file it finds only.

Comment by Sergei Golubchik [ 2017-05-31 ]

yes, I've noticed that too, this looked strange to I asked the author for the confirmation. it's MDEV-12965 now.

Comment by Olaf van der Spek [ 2017-05-31 ]

Thanks, what about the other points?

Comment by Sergei Golubchik [ 2017-05-31 ]

What I told about paths (including %HOMEPATH%) was, basically, directly copied from ma_default.c.

When MDEV-12965 is fixed, libmariadb should do what https://mariadb.com/kb/en/mariadb/configuring-mariadb-with-mycnf/ says.

Comment by Olaf van der Spek [ 2017-05-31 ]

But https://mariadb.com/kb/en/mariadb/configuring-mariadb-with-mycnf/ says nothing about HOMEPATH on Windows does it? So IMO that page should be updated as well.
Then there's item 2, which is separate from item 4. And there's item 3.

Comment by Sergei Golubchik [ 2017-05-31 ]

Yes, I took HOMEPATH from ma_default.c. KB doesn't say anything about HOMEPATH because the server and libmysqlclient don't look there. After MDEV-12965, libmariadb will be doing the same. That is, it will do what KB page says.

Comment by Olaf van der Spek [ 2017-05-31 ]

It'd actually be nice if the client did, to mimic the behaviour on Linux.
An unprivileged user might not have write access to the other locations.

Comment by Olaf van der Spek [ 2018-03-14 ]

I can't get this to work.. I've tried both my.cnf and my.ini in c:\ and c:\windows
libmariadb:x86-windows 3.0.2

my.ini:
[client]
host = debian
user = root
password = 123

C:\vc\vcpkg\buildtrees\libmariadb\src\mariadb-connector-c-3.0.2\libmariadb\ma_default.c: 275:
set_option(mysql, "host ", "ebian");

The trailing space and the missing first char are NOT typos..

Generated at Thu Feb 08 08:01:50 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.