Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-124

Default socket path for programs linked with libmariadbclient.a

Details

    • Bug
    • Status: Closed (View Workflow)
    • Trivial
    • Resolution: Not a Bug
    • None
    • 2.0.0
    • None
    • None
    • 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 ?

      Attachments

        Activity

          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?

          jsiebert Jarosław Siebert added a comment - 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?
          georg Georg Richter added a comment -

          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");

          georg Georg Richter added a comment - 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");
          otto Otto Kekäläinen added a comment - Merge request on the topic submitted downstream: https://salsa.debian.org/mariadb-team/mariadb-connector-c/merge_requests/2

          People

            georg Georg Richter
            jsiebert Jarosław Siebert
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.