Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 656084 - dev-db/mysql-5.7.22 emerge --config multiple failures
Summary: dev-db/mysql-5.7.22 emerge --config multiple failures
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Linux MySQL bugs team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-19 00:28 UTC by Hank Leininger
Modified: 2018-05-21 23:12 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Updated mysql-5.7 ebuild that fixes --config (mysql-5.7.22.ebuild,26.43 KB, text/plain)
2018-05-19 00:30 UTC, Hank Leininger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hank Leininger 2018-05-19 00:28:41 UTC
Encountered three distinct issues with emerge --config dev-db/mysql with a fresh install of 5.7.22.

Workarounds for all of them below, and I'll upload an updated .ebuild that incorporates all changes.

None of these occur with mysql-5.6 - some are caused by changes in MySQL 5.7.x, others might be problems with the 5.7.22 ebuild's private pkg_config function rather than the one in mysql-multilib-r1.eclass, I dunno.

First:

pkg_config() creates a tempfile as root mode 600, writes data to it, and then su's to mysql a command that attempts to read that file in, which fails:

# emerge --config dev-db/mysql
...
 * Command: /usr/sbin/mysqld --initialize-insecure --init-file='/var/tmp/portage/dev-db/mysql-5.7.22/temp/tmp.jhKyTO2ds1' --basedir=/usr --loose-skip-grant-tables --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 --datadir=///var/lib/mysql --tmpdir=///tmp/
 * ERROR: dev-db/mysql-5.7.22::gentoo failed (config phase):
 *   Failed to initialize mysqld. Please review /var/log/mysql/mysqld.err AND /var/tmp/portage/dev-db/mysql-5.7.22/temp/mysql_install_db.log
...

Note the --init-file='/var/tmp/portage/dev-db/mysql-5.7.22/temp/tmp.jhKyTO2ds1' argument; that file is only readable by root:

-rw------- 1 root root 1622190 May 18 16:33 /var/tmp/portage/dev-db/mysql-5.7.22/temp/tmp.jhKyTO2ds1

pkg_config() creates that file:

        local sqltmp="$(emktemp)"

writes to it:

        "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null

and then su - mysql a command that attempts to read it:

        local cmd=( "${EROOT}usr/sbin/mysqld" "--initialize-insecure" "--init-file='${sqltmp}'" )
        cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" )
        einfo "Command: ${cmd[*]}"
        su -s /bin/sh -c "${cmd[*]}" mysql \
                >"${TMPDIR}"/mysql_install_db.log 2>&1

Of course that fails.

Simple workaround, probably not the right way to do it, chown the file to mysql before attempting to read back as that user:

--- mysql-5.7.22.ebuild.orig 2018-05-16 16:43:00.970184908 -0600
+++ mysql-5.7.22.ebuild     2018-05-18 17:51:04.742219593 -0600
@@ -780,6 +780,7 @@
        # Filling timezones, see
        # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
        "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
+       chown mysql "${sqltmp}" || die
 
        # --initialize-insecure will not set root password
        # --initialize would set a random one in the log which we don't need as we set it ourselves


That allows it to get further before dying with a different error.

Second:

From mysqld.err:

...
2018-05-18T20:46:16.849929Z 1 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T20:46:16.849942Z 1 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-05-18T20:46:21.706727Z 1 [ERROR] 1146  Table 'sys.time_zone' doesn't exist
2018-05-18T20:46:21.707026Z 0 [ERROR] Aborting

The "sys" schema is new in 5.7.x, and it doesn't have a time_zone table, but the "mysql" DB does.  My guess is --init-file used to apply SQL commands to the mysql database (by default, or by luck) and now applies them to sys, causing it to fail now.  Unsure if this counts as an upstream bug.

Workaround: add a 'USE mysql' to the beginning of the zoneinfo file:

--- mysql-5.7.22.ebuild.chown   2018-05-18 18:08:35.609036824 -0600
+++ mysql-5.7.22.ebuild 2018-05-18 15:07:28.258624882 -0600
@@ -779,7 +779,8 @@
 
        # Filling timezones, see
        # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
-       "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
+       echo "USE mysql;" >"${sqltmp}"
+       "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${sqltmp}" 2>/dev/null
        chown mysql "${sqltmp}" || die
 
        # --initialize-insecure will not set root password


Third problem:

# emerge --config dev-db/mysql
...

 * Setting root password ...
ERROR 1054 (42S22) at line 1: Unknown column 'Password' in 'field list'


This is because the Password field has been renamed.  Fix for that:

--- mysql-5.7.22.ebuild.use_mysql       2018-05-18 15:07:28.258624882 -0600
+++ mysql-5.7.22.ebuild 2018-05-18 15:21:46.218623962 -0600
@@ -831,7 +831,7 @@
 
        ebegin "Setting root password"
        # Do this from memory, as we don't want clear text passwords in temp files
-       local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
+       local sql="UPDATE mysql.user SET authentication_string = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
        "${EROOT}/usr/bin/mysql" \
                "--socket=${socket}" \
                -hlocalhost \


Reproducible: Always

Steps to Reproduce:
1. Emerge dev-db/mysql-5.7.22 on a fresh box, no /var/lib/mysql directory
2. emerge --config dev-db/mysql
3. Weep.
Comment 1 Hank Leininger 2018-05-19 00:30:35 UTC
Created attachment 532106 [details]
Updated mysql-5.7 ebuild that fixes --config
Comment 2 Larry the Git Cow gentoo-dev 2018-05-19 02:35:38 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=861d31197c4cb91f2e29c8992febc371cd55e602

commit 861d31197c4cb91f2e29c8992febc371cd55e602
Author:     Brian Evans <grknight@gentoo.org>
AuthorDate: 2018-05-19 02:34:54 +0000
Commit:     Brian Evans <grknight@gentoo.org>
CommitDate: 2018-05-19 02:35:30 +0000

    dev-db/mysql: Fine tune pkg_config in 5.7.22
    
    Hank Leininger noticed there were errors in the new 5.7 pkg_config
    
    I took 2 of his suggestions but used a more standard password
    setting method which will work in future versions.
    
    Also prep for EAPI 7 paths in pkg_config
    
    Closes: https://bugs.gentoo.org/656084
    Package-Manager: Portage-2.3.37, Repoman-2.3.9

 dev-db/mysql/mysql-5.7.22.ebuild | 73 +++++++++++++++++++++-------------------
 1 file changed, 38 insertions(+), 35 deletions(-)
Comment 3 Hank Leininger 2018-05-21 23:12:16 UTC
Thanks for the quick turn-around!

Confirmed, a fresh install and emerge --config of dev-db/mysql-5.7.22 now is successful.