Bug #86523 ALTER USER root operation failed
Submitted: 31 May 2017 12:38 Modified: 17 Aug 2017 14:33
Reporter: Thomas Liddle Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Package Repos and Docker Images Severity:S3 (Non-critical)
Version:1.0.0 OS:Oracle Linux
Assigned to: CPU Architecture:Any
Tags: 5.7.18

[31 May 2017 12:38] Thomas Liddle
Description:
Using the Dockerfile on the docker hub mysql/mysql-server generates the following error when starting up the Docker container and reviewing the docker logs for that container

ERROR 1396 (HY000) at line 1: Operation ALTER USER failed for 'root'@'%'

It seems to be generated in the entrypoint.sh script on this line
               if [ ! -z "$MYSQL_ONETIME_PASSWORD" ]; then
                        "${mysql[@]}" <<-EOSQL
                                ALTER USER 'root'@'%' PASSWORD EXPIRE;
                        EOSQL

How to repeat:
Download the Dockerfile from Docker hub

#> docker build -t mysql/mysql-server-custom:5.7.18 .

#> docker run -p 3306:3306 --name dlmysql01 -e MYSQL_ROOT_PASSWORD=root?pwd -e MYSQL_ROOT_HOST=172.17.0.1 -d mysql/mysql-server-custom:5.7.18

#> docker start dlmysql01

#> docker logs dlmysql01
Initializing database
Database initialized
MySQL init process in progress...
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
GENERATED ROOT PASSWORD: sYfJOqLYMh4kyRtISvyf-imZYD

/entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

ERROR 1396 (HY000) at line 1: Operation ALTER USER failed for 'root'@'%'

Suggested fix:
It seems to be generated in the entrypoint.sh script on this line
               if [ ! -z "$MYSQL_ONETIME_PASSWORD" ]; then
                        "${mysql[@]}" <<-EOSQL
                                ALTER USER 'root'@'%' PASSWORD EXPIRE;
                        EOSQL

I don't have a suggested fix.
[1 Jun 2017 5:12] Lars Tangvald
Issue is that that part of the code wasn't properly updated when the default root user was restricted from @% to @localhost, so it's trying to alter a user that doesn't exist.
[8 Jun 2017 8:30] Lars Tangvald
This should now be fixed in mysql/mysql-server:5.7-dev. Can you verify that this tag fixes your issue?
[17 Aug 2017 14:33] Lars Tangvald
Posted by developer:
 
This is fixed in the new 1.1.0 release