Summary: | databases/mariadb104-server: my.cnf no longer found unter /usr/local/etc | ||||||
---|---|---|---|---|---|---|---|
Product: | Ports & Packages | Reporter: | theis | ||||
Component: | Individual Port(s) | Assignee: | Bernard Spil <brnrd> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Only Me | CC: | eborisch+FreeBSD, paulbeard, rshare, vvd | ||||
Priority: | --- | Flags: | bugzilla:
maintainer-feedback?
(brnrd) |
||||
Version: | Latest | ||||||
Hardware: | Any | ||||||
OS: | Any | ||||||
See Also: | https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247859 | ||||||
Attachments: |
|
Description
theis
2020-05-24 13:33:59 UTC
The latest revision 10.4.13_1 removed these lines from the post-patch section of the Makefile: ${REINPLACE_CMD} 's|/usr/bin/env python|${PYTHON_CMD}|' ${WRKSRC}/CMakeLists.txt ${REINPLACE_CMD} 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/mysys/my_default.c ${REINPLACE_CMD} 's|%%LOCALBASE%%|${LOCALBASE}|g' ${WRKSRC}/scripts/mysql_config.sh \ and only left ${REINPLACE_CMD} 's|%%LOCALBASE%%|${LOCALBASE}|g' \ ${WRKSRC}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake Now on my machine mysqld is looking for the my.cnf file in %%PREFIX%%/etc instead of /usr/local/etc, so I guess the seds related to %%PREFIX%% shouldn't have been removed, or the patch that puts these into the source needs to be adapted, too. When I put the seds back into the Makefile and build the port again, it works as expected. Sorry for this! Fix coming up, taken a bit longer as it is part of an overhaul of the port. A commit references this bug: Author: brnrd Date: Tue May 26 09:58:41 UTC 2020 New revision: 536602 URL: https://svnweb.freebsd.org/changeset/ports/536602 Log: databases/mariadb104-server: Fix configuration location / overhaul * Fix configuration location [1] * Share patches between client and server * Provide minimal configuration for client and server * Make the wsrep config a sample only * Fixup plists PR: 246694 [1] Reported by: <theis gmx at> MFH: 2020Q2 Changes: head/databases/mariadb104-client/Makefile head/databases/mariadb104-client/files/ head/databases/mariadb104-client/pkg-plist head/databases/mariadb104-server/Makefile head/databases/mariadb104-server/files/client.cnf.sample.in head/databases/mariadb104-server/files/my.cnf.sample.in head/databases/mariadb104-server/files/patch-man_CMakeLists.txt head/databases/mariadb104-server/files/pkg-message.in head/databases/mariadb104-server/files/server.cnf.sample.in head/databases/mariadb104-server/pkg-plist No problem and thanks for the fix. Wouldn't it make sense to add a notice somewhere (UPDATING or pkg message) that the location was wrong? It could have affected more people who may not be aware of it. And in my case I had to manually intervene to make sure replication is working again. In databases/mariadb104-server/files/mysql-server.in file should be something like this: if [ ! -d /var/run/${name} ]; then install -d -o %%USERS%% -g %%GROUPS%% /var/run/${name} fi (In reply to theis from comment #4) 20200526: AFFECTS: users of databases/mariadb104-client, databases/mariadb104-server AUTHOR: brnrd@FreeBSD.org The ports now add sample configuration files to /usr/local/etc/mysql. You must merge your client configation with the conf.d/client.cnf and your server configuration with conf.d/server.cnf. (In reply to VVD from comment #5) Into mysql_prestart(). Is it a result of the changes that PHP's mysqli_connect cannot connect to localhost anymore and I have to use 127.0.0.1 instead? (In reply to theis from comment #8) /var/run/mysql/mysql.sock instead /tmp/mysql.sock You have to set: mysqli.default_socket = /var/run/mysql/mysql.sock There are 2 other: pdo_mysql.default_socket = /var/run/mysql/mysql.sock mysql.default_socket = /var/run/mysql/mysql.sock (In reply to VVD from comment #9) In /usr/local/etc/php.ini file. I have a server with a dozen or so PHP applications running, each using mariadb. So my question is not "how do I configure mysqli connector" but "why do I have to change my configurations from localhost to its IP address". That shouldn't make a difference. Maybe it was a change I did in the past, my initial installation of PHP was a couple of years before. But it could also be a change which came with the last update and then many other people would be affected. I can't test it at the moment, I don't have a system with a fresh installation of mariadb and e.g. phpMyAdmin at hand. (In reply to theis from comment #11) > "why do I have to change my configurations from localhost to its IP address" You do not have to do this. Ah, the fog begins to lift: mysqli uses unix sockets when you use 'localhost' as a host name and TCP when you use '127.0.0.1'. And don't forget to restart Apache ... :) (In reply to theis from comment #13) > Ah, the fog begins to lift: mysqli uses unix sockets when you use 'localhost' as a host name and TCP when you use '127.0.0.1'. > > And don't forget to restart Apache ... :) Exactly! It took me 30 minutes to solve this issue… (In reply to VVD from comment #9) I'm not fully sure why this happens. The client should default to ${LOCALBASE}/etc/my.cnf first. ONLY if you have no my.cnf there should it fall back to the (new) ${LOCALBASE}/etc/mysql/my.cnf > $ mysql --help | head > mysql Ver 15.1 Distrib 10.4.13-MariaDB, for FreeBSD12.1 (amd64) using EditLine wrapper > Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. > > Usage: mysql [OPTIONS] [database] > > Default options are read from the following files in the given order: > /usr/local/etc/my.cnf /usr/local/etc/mysql/my.cnf ~/.my.cnf (In reply to Bernard Spil from comment #15) Just dawned on me... If you hadn't previously configured anything, the socket would default to /tmp/mysql.sock. This now changed to a more appropriate /var/run/mysql/mysql.sock. This isn't sufficiently reflected in the UPDATING entry. Sorry for the inconvenience! I'll align the default socket patch in a future update! (In reply to Bernard Spil from comment #16) And, plz, do this: > In databases/mariadb104-server/files/mysql-server.in file should be something like this: mysql_prestart() { … if [ ! -d "/var/run/${name}" ]; then install -d -o %%USERS%% -g %%GROUPS%% /var/run/${name} fi } (In reply to Bernard Spil from comment #16) Exactly. I wasn't even aware (PHP) clients were using unix sockets and not TCP. I think the new location of the socket is better. The problem is I wasn't aware it changed. An entry about it, and how to change it back, in UPDATING may have helped. Do you know if (PHP) clients, esp. mysqli, are supposed to read my.cnf? If so, then I just missed "restart apache". If not things become more complicated ... (In reply to theis from comment #18) > o you know if (PHP) clients, esp. mysqli, are supposed to read my.cnf? If so, then I just missed "restart apache". If not things become more complicated ... I don't know. Perhaps they don't use my.cnf at all… For me application with pdo_mysql (MODX) didn't work until I set pdo_mysql.default_socket=/var/run/mysql/mysql.sock in /usr/local/etc/php.ini and restart apache. Same with MediaWiki with mysqli: didn't work until I set mysqli.default_socket=/var/run/mysql/mysql.sock in /usr/local/etc/php.ini and restart apache. But! Both my pdo_mysql and mysqli are php 5.6. But I don't think that the current versions for 7.x have changed the behavior. Sorry for all the inconvenience due to this POLA violation! The 10.4.13_1 version was broken, 10.4.13_2 fixed that but introduced side-effects. The addition of the ${ETCDIR}/my.cnf, local.cnf and server.cnf files may overlap with your current configuration. Hence the UPDATING entry. Please always verify the paths using methods below 10.4.13_1 > root@db:/root$ mysql --help | head > mysql Ver 15.1 Distrib 10.4.13-MariaDB, for FreeBSD12.1 (amd64) using EditLine wrapper > Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. > > Usage: mysql [OPTIONS] [database] > > Default options are read from the following files in the given order: > /usr/local/etc/my.cnf ~/.my.cnf > root@db:/root$ /usr/local/libexec/mysqld --verbose --help | head > 2020-05-30 15:36:12 0 [Note] Plugin 'FEEDBACK' is disabled. > 2020-05-30 15:36:12 0 [Warning] Could not open mysql.plugin table. Some options may be missing from the help text > /usr/local/libexec/mysqld Ver 10.4.13-MariaDB for FreeBSD12.1 on amd64 (FreeBSD Ports) > Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. > > Starts the MariaDB database server. > > Usage: /usr/local/libexec/mysqld [OPTIONS] > > Default options are read from the following files in the given order: > %%PREFIX%%/etc/my.cnf %%PREFIX%%/etc/mysql/my.cnf ~/.my.cnf > The following groups are read: mysqld server mysqld-10.4 mariadb mariadb-10.4 mariadbd mariadbd-10.4 client-server Note how this is broken: PREFIX wasn't replaced by REINPLACE_CMD in PORTREVISION=1 Also note how client and server differ in location of my.cnf files. Then came PORTREVISION=2 > root@db:/root$ mysql -h | head > mysql: option '-h' requires an argument > root@db:/root$ mysql --help | head > mysql Ver 15.1 Distrib 10.4.13-MariaDB, for FreeBSD12.1 (amd64) using EditLine wrapper > Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. > > Usage: mysql [OPTIONS] [database] > > Default options are read from the following files in the given order: > /usr/local/etc/my.cnf /usr/local/etc/mysql/my.cnf ~/.my.cnf > The following groups are read: mysql mariadb-client client client-server client-mariadb > The following options may be given as the first argument: > --print-defaults Print the program argument list and exit. > root@db:/root$ /usr/local/libexec/mysqld --verbose --help | head > 2020-05-31 9:13:56 0 [Note] Plugin 'FEEDBACK' is disabled. > 2020-05-31 9:13:56 0 [Warning] Could not open mysql.plugin table. Some options may be missing from the help text > /usr/local/libexec/mysqld Ver 10.4.13-MariaDB for FreeBSD12.1 on amd64 (FreeBSD Ports) > Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. > > Starts the MariaDB database server. > > Usage: /usr/local/libexec/mysqld [OPTIONS] > > Default options are read from the following files in the given order: > /usr/local/etc/my.cnf /usr/local/etc/mysql/my.cnf ~/.my.cnf > The following groups are read: mysqld server mysqld-10.4 mariadb mariadb-10.4 mariadbd mariadbd-10.4 client-server Note that both client and server use the same configuration files. Also note that the commit adds 4 sample configuration files in ${ETCDIR}/. One unifying my.cnf file that includes conf.d/*.cnf: a client.cnf for mariadb104-client and a server.cnf for mariadb104-server (and wsrep.cnf only as a sample). Where this goes wrong is when you DIDN'T have a my.cnf in ${PREFIX}/etc/my.cnf. It will now apply defaults from client.cnf which are different from the defaults in the binary file (mysys/my_default.c). Lastly, mariadb104-server will use /var/db/mysql/my.cnf file unless you define mysql_optfile in rc.conf. This is all a historical thing I inherited when I took maintainership of the MariaDB ports in 2017 (after prior involvement since 2014). Ahead is more churn. I want to make to force the port to use hier (7) 1. Remove files/patch-mysys_my__default.c, replace with CMAKE_ARGS+= DEFAULT_SYSCONFDIR=${ETCDIR} 2. Default mysql_optfile to ${ETCDIR}/my.cnf (i.e. etc/mysql/mysql.cnf) 3. Remove as many patches as possible This will be default in 10.5 at minimum. Maintaining these ports is too labor instensive, hence I a deprecating older versions. Again, sorry for your inconvenience! (please keep providing feedback and patches and PRs!) (In reply to Bernard Spil from comment #20) Dear Bernard, First thank you for your work as maintainer. I know this is not easy with MariaDB being such a large port and having ties into so many others. Also I like the new config layout. And the new location of mysql.sock is better than the old one. If you had just added a hint in UPDATING that you changed the default of mysql.sock and how / where to set it back to before. That's all I missed :) Btw., I did have a /usr/local/etc/my.cnf, it just had settings for replication. Maybe that caused some problems? Anyway, I got it working again, I understand somewhat better how it works. And thank you again for spending so much time into improving MariaDB! Created attachment 215110 [details]
mkdir /var/run/mysql during install
Without it (/var/run/mysql) server didn't start silently during trying create /var/run/mysql/mysql.sock file.
Comment on attachment 215110 [details]
mkdir /var/run/mysql during install
Looks very good to me!
The patch to create /var/run/mysql during install has not been applied, so updated servers (beyond the conf.d POLA issue) silently fail when starting. Thanks for the hard work maintaining the port! (In reply to Bernard Spil from comment #23) Bernard, commit it, plz. (In reply to VVD from comment #25) Possible 10.1, 10.2, 10.3 and other mysql clones need this patch too. A commit references this bug: Author: brnrd Date: Sun Jun 21 13:32:28 UTC 2020 New revision: 539762 URL: https://svnweb.freebsd.org/changeset/ports/539762 Log: MFH: r536602 databases/mariadb104-server: Fix configuration location / overhaul * Fix configuration location [1] * Share patches between client and server * Provide minimal configuration for client and server * Make the wsrep config a sample only * Fixup plists PR: 246694 [1] Reported by: <theis gmx at> Approved by: ports-secteam (joneum) Changes: _U branches/2020Q2/ branches/2020Q2/databases/mariadb104-client/Makefile branches/2020Q2/databases/mariadb104-client/files/ branches/2020Q2/databases/mariadb104-client/pkg-plist branches/2020Q2/databases/mariadb104-server/Makefile branches/2020Q2/databases/mariadb104-server/files/client.cnf.sample.in branches/2020Q2/databases/mariadb104-server/files/my.cnf.sample.in branches/2020Q2/databases/mariadb104-server/files/patch-man_CMakeLists.txt branches/2020Q2/databases/mariadb104-server/files/pkg-message.in branches/2020Q2/databases/mariadb104-server/files/server.cnf.sample.in branches/2020Q2/databases/mariadb104-server/pkg-plist Still no sign of /var/run/mysql being made in -server/Makefile or in the plist... Or has something else changed to remove the need for it? (In reply to eborisch+FreeBSD from comment #28) Patch with this is here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247747#c7 A search for my mariadb server won't accept connections brought me here. Lost power the other night which may have corrupted the database but before I can restore a backup, I need it to run. Not having any success loading my.cnf from rc.conf or running at all. `cat /usr/local/etc/mysql/my.cnf # # This group is read both by the client and the server # use it for options that affect everything, see # https://mariadb.com/kb/en/configuring-mariadb-with-option-files/#option-groups # [client-server] port = 3306 #socket = /tmp/mysql.sock socket = /var/run/mysql/mysql.sock ` ` /usr/local/bin/mariadb-install-db --defaults-file=/usr/local/etc/mysql/my.cnf Installing MariaDB/MySQL system tables in '/var/db/mysql' ... Abort trap … ` [root@www /var/db/mysql]# 2021-10-29 17:43:51 0 [Note] /usr/local/libexec/mysqld (mysqld 10.5.12-MariaDB-log) starting as process 3103 ... mysql -uroot ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' There is no such socket…the default still seems to be /tmp/mysql.sock Where should I expect to find the socket if I don't specify it? pkg info maria* mariadb105-client-10.5.12_1 mariadb105-server-10.5.12_1 Looks like a recent power outage corrupted my database: reinstalling and starting from scratch was the only way forward. But I just tested using my.cnf to define the mysql.sock location and it still defaults to /tmp/mysql.sock. I can work with it but that sort of thing makes me wonder what else is being silently ignored. I am leaving this system on 11.4 so no updates will reach me. There may be a way to accept port upgrades/bypass the EOL warning but I don't know of one. |