[mythtv-users] error during upgrade from V30 to V31
Bill Meek
keemllib at gmail.com
Tue Mar 24 19:47:19 UTC 2020
On 3/24/20 1:45 PM, James Abernathy wrote:
> On Tue, Mar 24, 2020 at 2:37 PM Bill Meek <keemllib at gmail.com> wrote:
...
>> Hmmm, this looks like something that was fixed got reverted. It's still OK
>> in our packaging tree.
>>
>> Jim,
>>
>> Please look in: /var/lib/dpkg/info/mythtv-database.postinst
>>
>> There should be a lines like these:
>>
>> update_database() {
>> #Set up privs for mythtv at network
>> if ! echo "CREATE USER IF NOT EXISTS '$mythtv_username'@'%'
>> IDENTIFIED WITH mysql_native_password; \
>> ALTER USER '$mythtv_username'@'%' IDENTIFIED BY
>> '$mythtv_password'; \
>> GRANT ALL ON $database.* TO '$mythtv_username'@'%';" | \
>> mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
>> fail_database
>> fi
>>
>> But it appears that you'll see:
>>
>> update_database() {
>> #Set up privs for mythtv at network
>> if ! echo "GRANT ALL PRIVILEGES ON $database.* TO $mythtv_username@'%'
>> IDENTIFIED BY '$mythtv_password';" | \
>> mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
>> fail_database
>> fi
>>
>> --
>> Bill
>>
> I see
>
> update_database() {
> #Set up privs for mythtv at network
> if ! echo "CREATE USER IF NOT EXISTS '$mythtv_username'@'%' IDENTIFIED
> WITH mysql_native_password; \
> ALTER USER '$mythtv_username'@'%' IDENTIFIED BY
> '$mythtv_password'; \
> GRANT ALL ON $database.* TO '$mythtv_username'@'%';" | \
> mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
> fail_database
> fi
That's good.
Can you login as the root user using the credentials in: /etc/mysql/debian.cnf ?
This works for me: sudo mysql --defaults-extra-file=/etc/mysql/debian.cnf on
MariaDB and MySQL v5.7 and 8.
If that fails, your earlier comment about ' admin username and password' may
explain things. Otherwise, please read on...
The attached has some debugging info in it. I'd rename the existing file
and put this one in. Make sure to chmod 755 on it.
Then re-run: sudo dpkg-reconfigure mythtv-database
Additional information will print in the failure message. At least it would get
it down to the area that's failing.
Remove the file and re-rename the original /var/lib/dpkg/info/mythtv-database.postinst
file.
--
Bill
-------------- next part --------------
#!/bin/sh -e
MYSQL="/usr/share/mythtv/sql/mythtv*.sql"
MYSQLCONFIG="/etc/mysql/conf.d/mythtv.cnf"
MYSQLCONFIGUPDATEHINT="/etc/mysql/conf.d/mythtv.cnf.ipv6update-with-public_bind.tmp"
FSTAB="/etc/fstab"
LOCALHOSTNAME=`cat /etc/hostname`
NEWMYSQLCONFDIR="/etc/mysql/mysql.conf.d/"
#Used to fail at some point but not abort postinst
fail_database() {
echo "Failed to $1 database (incorrect admin username/password?)" >&2
echo "Try:" >&2
echo "sudo dpkg-reconfigure mythtv-database" >&2
db_set mythtv/mysql_admin_password ""
exit 0
}
#ask the root password a few times if it's still not working
ask_root_pw() {
db_input high mythtv/mysql_host || true
db_input high mythtv/mysql_admin_user || true
db_input high mythtv/mysql_admin_password || true
db_go || true
db_get mythtv/mysql_host
hostname="$RET"
db_get mythtv/mysql_admin_user
admin_username="$RET"
db_get mythtv/mysql_admin_password
admin_password="$RET"
if [ "$admin_password" != "" ]; then
admin_password="-p$admin_password"
fi
SECURITY_INFO="--host=$hostname --user=$admin_username $admin_password"
}
update_database() {
#Set up privs for mythtv at network
if ! echo "CREATE USER IF NOT EXISTS '$mythtv_username'@'%' IDENTIFIED WITH mysql_native_password; \
ALTER USER '$mythtv_username'@'%' IDENTIFIED BY '$mythtv_password'; \
GRANT ALL ON $database.* TO '$mythtv_username'@'%';" | \
mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
fail_database "create/alter user or grant permissions to"
fi
# load timezone data
if ! mysql_tzinfo_to_sql /usr/share/zoneinfo/ 2>/dev/null | mysql $SECURITY_INFO mysql >/dev/null 2>&1; then
fail_database "load timezone data to"
fi
}
case "$1" in
configure)
#Fixup mysql binding ipv6-compatibility config-update when public_bind was in use (hint from preinst)
if [ -f "${MYSQLCONFIG}" ]; then
if [ -f "${MYSQLCONFIGUPDATEHINT}" ]; then
sed -i -e 's/^#bind-address=::$/bind-address=::/' ${MYSQLCONFIG}
rm ${MYSQLCONFIGUPDATEHINT}
fi
fi
## This will need to exist until we no longer support 14.04
if [ -d "${NEWMYSQLCONFDIR}" ]; then
if [ ! -f "${NEWMYSQLCONFDIR}/mythtv.cnf" ]; then
ln -s "${MYSQLCONFIG}" "${NEWMYSQLCONFDIR}"
fi
fi
. /usr/share/debconf/confmodule
db_get mythtv/mysql_mythtv_dbname
database="$RET"
db_get mythtv/mysql_mythtv_user
mythtv_username="$RET"
db_get mythtv/mysql_mythtv_password
mythtv_password="$RET"
db_get mythtv/mysql_admin_user
admin_username="$RET"
if [ "$admin_username" = "debian-sys-maint" ]; then
SECURITY_INFO="--defaults-file=/etc/mysql/debian.cnf"
else
db_get mythtv/mysql_host
hostname="$RET"
db_get mythtv/mysql_admin_password
admin_password="$RET"
if [ "$admin_password" != "" ]; then
admin_password="-p$admin_password"
fi
SECURITY_INFO="--host=$hostname --user=$admin_username $admin_password"
fi
#If we are running locally, make sure to start mysql first
#It's okay if it fails, we'll fall back cleanly later
if [ "$hostname" = "localhost" ]; then
#redirection of 3 is because of debconf internally using it.
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d mysql start 3> /dev/null || true
else
/etc/init.d/mysql start 3> /dev/null || true
fi
fi
#For database fillings
#and mysql binding checks
if [ -f "${MYSQLCONFIG}" ]; then
db_get mythtv/public_bind
if [ -n "$RET" ] && [ $RET = true ]; then
sed -i -e 's/^#bind/bind/' ${MYSQLCONFIG}
else
sed -i -e 's/^bind/#bind/' ${MYSQLCONFIG}
fi
fi
#Check for existing database
if ! echo "SELECT NULL;" | mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
#No existing database, create a database
i=1
while ! echo "CREATE DATABASE $database;" | mysql $SECURITY_INFO ; do
#>/dev/null 2>&1; do
if [ $i -ge 5 ]; then
fail_database "create"
fi
ask_root_pw
i=$(($i+1))
done
fi
#Update Permissions
update_database
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
db_set mythtv/mysql_admin_password ""
db_set mythtv/mysql_mythtv_password ""
exit 1
;;
esac
#DEBHELPER#
db_set mythtv/mysql_admin_password ""
db_set mythtv/mysql_mythtv_password ""
exit 0
More information about the mythtv-users
mailing list