[CONC-124] Default socket path for programs linked with libmariadbclient.a Created: 2015-02-23  Updated: 2018-10-26  Resolved: 2015-02-23

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0.0

Type: Bug Priority: Trivial
Reporter: Jarosław Siebert Assignee: Georg Richter
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

Archlinux, Slackware



 Description   

When I try to connect to mariadb server with program linked with libmariadbclient.a over local connection, then it reports:
mysql_real_connect:Can't connect to local MySQL server through socket '/tmp/mysql.sock'
My mysql setup in /etc/mysql/my.cnf uses:
socket = /run/mysqld/mysqld.sock
for [client] and [mysqld] section.
Howto setup connection in C program to use default socket path from
/etc/mysql/my.cnf ?



 Comments   
Comment by Jarosław Siebert [ 2015-02-23 ]

I found the solution:
I need to read config file with:
mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, path);
Howto find what is the default setup path?
Do I need to manually chek if /etc/my.cnf or /etc/mysql/my.cnf or there is
better way to read my.cnf from default config directory?

Comment by Georg Richter [ 2015-02-23 ]

Neither libmysql or libmariadb read from configuration file by default.

To read configuration options from my.cnf you need to set option MYSQL_READ_DEFAULT_GROUP:

mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "client");

Comment by Otto Kekäläinen [ 2018-10-26 ]

Merge request on the topic submitted downstream: https://salsa.debian.org/mariadb-team/mariadb-connector-c/merge_requests/2

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