A fresh installation with password in ~/.my.cnf: # cat /root/.my.cnf [mysql] user=root password=... [client] user=root password=... [mysqldump] user=root password=... # emerge --config mariadb Configuring pkg... * Creating mariadb log-bin directory 'mysqld-bin' ... * Creating mariadb relay-log directory 'mysqld-relay-bin' ... * Detected settings: * ================== * MySQL User: mysql * MySQL Group: mysql * MySQL DATA directory: /var/lib/mysql * MySQL TMP directory: /tmp * MySQL Binary Log File location: mysqld-bin * MySQL Relay Log File location: mysqld-relay-bin * PID DIR: /run/mysqld * Install db log: /tmp/mariadb-config.d9skcjAhZ/install_db.log * Install server log: /tmp/mariadb-config.d9skcjAhZ/mysqld.log * Trying to get password for mysql 'root' user from 'mysql' section ... * Found password in 'mysql' section! * Initializing mariadb data directory: /usr/bin/mysql_install_db --loose-skip-host-cache --loose-skip-name-resolve --loose-skip-networking --loose-skip-slave-start --loose-skip-ssl --loose-skip-log-bin --loose-skip-relay-log --loose-skip-slow-query-log --loose-skip-external-locking --loose-skip-log-slave-updates --init-file='/tmp/mariadb-config.d9skcjAhZ/tz.sql' --basedir='/usr' --datadir='/var/lib/mysql' --tmpdir='/tmp' --log-error='/tmp/mariadb-config.d9skcjAhZ/install_db.log' --rpm --cross-bootstrap --skip-test-db --user=mysql * Starting mysqld to finalize initialization: /usr/sbin/mysqld --loose-skip-host-cache --loose-skip-name-resolve --loose-skip-networking --loose-skip-slave-start --loose-skip-ssl --loose-skip-log-bin --loose-skip-relay-log --loose-skip-slow-query-log --loose-skip-external-locking --loose-skip-log-slave-updates --basedir='/usr' --datadir='/var/lib/mysql' --tmpdir='/tmp' --max_allowed_packet=8M --net_buffer_length=16K --socket='/run/mysqld/mysqld.21789.sock' --pid-file='/run/mysqld/mysqld.21789.pid' --log-error='/tmp/mariadb-config.d9skcjAhZ/mysqld.log' --user=mysql Waiting for mysqld to accept connections ..... * Setting root password ... [ ok ] Stopping the server . * mariadb data directory at '/var/lib/mysql' successfully initialized! # /etc/init.d/mysql restart * Starting mysql ... [ ok ] # mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) Debug log: + echo -e 'Trying to get password for mysql '\''root'\'' user from '\''mysql'\'' section ...' + read -r + echo ' * Trying to get password for mysql '\''root'\'' user from '\''mysql'\'' section ...' * Trying to get password for mysql 'root' user from 'mysql' section ... + read -r + LAST_E_CMD=einfo + return 0 ++ _getoptval mysql password ++ local section=mysql ++ local flag=--password= ++ local extra_options= ++ cmd=('/usr/bin/my_print_defaults' '' 'mysql') ++ local cmd +++ eval /usr/bin/my_print_defaults '' mysql +++ sed -n '/^--password=/s,--password=,,gp' ++ results=('mysqld-bin' 'mysqld-relay-bin') ++ local results ++ [[ 2 -gt 0 ]] ++ echo mysqld-relay-bin + MYSQL_ROOT_PASSWORD=mysqld-relay-bin + [[ -n mysqld-relay-bin ]] + [[ mysqld-relay-bin == *\ * ]] + einfo 'Found password in '\''mysql'\'' section!' + __elog_base INFO 'Found password in '\''mysql'\'' section!' With password "mysqld-relay-bin" it really works, except it's not the password that's in /root/.my.cnf :)
I cannot reproduce: > (chroot) hv-gentoo-x64 /tmp # cat ~/.my.cnf > [mysql] > user=root > password=secret > > [client] > user=root > password=secret_client > > [mysqldump] > user=root > password=secret_dump > > (chroot) hv-gentoo-x64 /tmp # emerge --config mariadb > > > Configuring pkg... > > * Creating mariadb data directory '/var/lib/mysql' ... > > * Detected settings: > * ================== > * MySQL User: mysql > * MySQL Group: mysql > * MySQL DATA directory: /var/lib/mysql > * MySQL TMP directory: /tmp > * PID DIR: /run/mysqld > * Install db log: /tmp/mariadb-config.n1bK4JS13/install_db.log > * Install server log: /tmp/mariadb-config.n1bK4JS13/mysqld.log > > * Trying to get password for mysql 'root' user from 'mysql' section ... > * Found password in 'mysql' section! > * Initializing mariadb data directory: /usr/bin/mysql_install_db --loose-skip-host-cache --loose-skip-name-resolve --loose-skip-networking --loose-skip-slave-start --loose-skip-ssl --loose-skip-log-bin --loose-skip-relay-log --loose-skip-slow-query-log --loose-skip-external-locking --loose-skip-log-slave-updates --init-file='/tmp/mariadb-config.n1bK4JS13/tz.sql' --basedir='/usr' --datadir='/var/lib/mysql' --tmpdir='/tmp' --log-error='/tmp/mariadb-config.n1bK4JS13/install_db.log' --rpm --cross-bootstrap --skip-test-db --user=mysql > * Starting mysqld to finalize initialization: /usr/sbin/mysqld --loose-skip-host-cache --loose-skip-name-resolve --loose-skip-networking --loose-skip-slave-start --loose-skip-ssl --loose-skip-log-bin --loose-skip-relay-log --loose-skip-slow-query-log --loose-skip-external-locking --loose-skip-log-slave-updates --basedir='/usr' --datadir='/var/lib/mysql' --tmpdir='/tmp' --max_allowed_packet=8M --net_buffer_length=16K --socket='/run/mysqld/mysqld.15797.sock' --pid-file='/run/mysqld/mysqld.15797.pid' --log-error='/tmp/mariadb-config.n1bK4JS13/mysqld.log' --user=mysql > Waiting for mysqld to accept connections ..... > * Setting root password ... [ ok ] > Stopping the server . > * mariadb data directory at '/var/lib/mysql' successfully initialized! > > > (chroot) hv-gentoo-x64 /tmp # /etc/init.d/mysql start > * Caching service dependencies ... > Service `netmount' needs non existent service `net' [ ok ] > * Checking mysqld configuration for mysql ... [ ok ] > * Starting mysql ... [ ok ] > > > (chroot) hv-gentoo-x64 /tmp # mysql -u root -psecret > Welcome to the MariaDB monitor. Commands end with ; or \g. > Your MariaDB connection id is 6 > Server version: 10.5.11-MariaDB-log Source distribution > > Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. > > Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. > > MariaDB [(none)]> exit > Bye > Please show your entire /etc/mysql/* config. Maybe your set log-bin/relay-log value is causing the different behavior.
These are present in 50-distro-server.cnf: log-bin = mysqld-bin relay-log = mysqld-relay-bin When removed, $(emerge --config) works fine.
OK, this was a tricky one. I added the following debug code to pkg_config: > set -x > rm -f /tmp/output.log /tmp/output2.log > > extra_options= > section=mysql > flag="--password=" > > echo "DIRECT START" > /usr/bin/my_print_defaults '' mysql > echo "DIRECT END" > > echo "DYNAMIC START" > "${my_print_defaults_binary}" "${extra_options}" ${section} > echo "DYNAMIC END" > > echo "ARRAY START" > cmd=(strace -s4096 -o /tmp/strace.log -- "${my_print_defaults_binary}" "${extra_options}" "${section}"); > blah1=($(eval "${cmd[@]}" 2>/dev/null | tee -a /tmp/output.log | sed -n "/^${flag}/s,${flag},,gp" | tee -a /tmp/output2.log)); > echo "${blah1[@]}" > echo "ARRAY END" > > set +x > die "DEBUG END" It will look like > (chroot) hv-gentoo-x64 / # emerge --config mariadb > > > Configuring pkg... > > ++ rm -f /tmp/output.log /tmp/output2.log > ++ extra_options= > ++ section=mysql > ++ flag=--password= > ++ echo 'DIRECT START' > DIRECT START > ++ /usr/bin/my_print_defaults '' mysql > --user=root > --password=***** > ++ echo 'DIRECT END' > DIRECT END > ++ echo 'DYNAMIC START' > DYNAMIC START > ++ /usr/bin/my_print_defaults '' mysql > --user=root > --password=***** > ++ echo 'DYNAMIC END' > DYNAMIC END > ++ echo 'ARRAY START' > ARRAY START > ++ cmd=(strace -s4096 -o /tmp/strace.log -- "${my_print_defaults_binary}" "${extra_options}" "${section}") > ++ blah1=($(eval "${cmd[@]}" 2>/dev/null | tee -a /tmp/output.log | sed -n "/^${flag}/s,${flag},,gp" | tee -a /tmp/output2.log)) > +++ tee -a /tmp/output.log > +++ eval strace -s4096 -o /tmp/strace.log -- /usr/bin/my_print_defaults '' mysql > +++ sed -n '/^--password=/s,--password=,,gp' > +++ tee -a /tmp/output2.log > ++ echo mysqld-bin mysqld-relay-bin > mysqld-bin mysqld-relay-bin > ++ echo 'ARRAY END' > ARRAY END > ++ set +x > * ERROR: dev-db/mariadb-10.3.31::local failed (config phase): > * DEBUG END > * > * Call stack: > * ebuild.sh, line 127: Called pkg_config > * environment, line 3834: Called source '/tmp/sql.sh' > * sql.sh, line 123: Called die > * The specific snippet of code: > * die "DEBUG END" At this point I still don't understand where "mysqld-bin mysqld-relay-bin" values are coming from because /usr/bin/my_print_defaults returned just > (chroot) hv-gentoo-x64 / # cat /tmp/output.log > --user=root > --password=***** and after the sed command we should only return > (chroot) hv-gentoo-x64 / # cat /tmp/output2.log > ***** Even strace shows that the command only returned > (chroot) hv-gentoo-x64 / # tail -n 3 /tmp/strace.log > write(1, "--user=root\n--password=*****\n", 29) = 29 > exit_group(0) = ? > +++ exited with 0 +++ When running manually, everything works: > (chroot) hv-gentoo-x64 / # /usr/bin/my_print_defaults '' mysql | sed -n '/^--password=/s,--password=,,gp' > ***** It's somehow related to > results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") ) which I am going to rewrite in a different way but I'd still like to understand where these values are coming from given that the called command won't return them.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=af7dba769693a706174ea2177ff7fde23eb8a394 commit af7dba769693a706174ea2177ff7fde23eb8a394 Author: Thomas Deutschmann <whissi@gentoo.org> AuthorDate: 2021-08-10 14:48:22 +0000 Commit: Thomas Deutschmann <whissi@gentoo.org> CommitDate: 2021-08-10 16:26:06 +0000 dev-db/mariadb: fix parameter parsing in pkg_config Bug: https://bugs.gentoo.org/801898 Package-Manager: Portage-3.0.21, Repoman-3.0.3 Signed-off-by: Thomas Deutschmann <whissi@gentoo.org> dev-db/mariadb/mariadb-10.2.40.ebuild | 25 ++++++++++++++++++++----- dev-db/mariadb/mariadb-10.3.31.ebuild | 25 ++++++++++++++++++++----- dev-db/mariadb/mariadb-10.4.21.ebuild | 25 ++++++++++++++++++++----- dev-db/mariadb/mariadb-10.5.12.ebuild | 25 ++++++++++++++++++++----- 4 files changed, 80 insertions(+), 20 deletions(-)
(In reply to Thomas Deutschmann from comment #3) > At this point I still don't understand where "mysqld-bin mysqld-relay-bin" > values are coming from because /usr/bin/my_print_defaults returned just > > > (chroot) hv-gentoo-x64 / # cat /tmp/output.log > > --user=root > > --password=***** I was wondering about the same, really strange. Just tested with 10.5.12, works as expected, thank you very much!