Mysql file import on arm64 gives access denied for user 'root'@'localhost'

Using mysql file import does not grant the root user access:

mysql -uroot < sql/create_mysql.sql

While the execution as root user works as expected:

mysql -uroot -e 'SHOW DATABASES;'

The problem is illustrated in the following repository:
https://travis-ci.org/github/damaex/travis-test

I’m not quite sure if this has anything to do with the different mysql version on arm64, but on amd64 everything works as desired.

Furthermore the output of the mysql command is different.

amd64:

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test_mysql         |
| travis             |
+--------------------+ 

arm64:

Database
information_schema
mysql
performance_schema
sys
test_mysql
1 Like

SHOW GRANTS reveals that root doesn’t have the GRANT OPTION in arm64. Other LXD environments (ppc64le and s390x) are also affected while arm64-graviton2 is not.

A workaround is to grant it by hand after restarting the server with skip-grant-tables as per https://stackoverflow.com/questions/1709078/how-can-i-restore-the-mysql-root-user-s-full-privileges :

install:
  - |
    if [[ $TRAVIS_CPU_ARCH == "arm64" ]]; then
      sudo bash -ec '
      echo -e '\''[mysqld]\\nskip-grant-tables'\'' >/etc/mysql/conf.d/grant.cnf
      systemctl restart mysql
      mysql -e "UPDATE mysql.user SET Grant_priv='\''Y'\'', Super_priv='\''Y'\'' WHERE User='\''root'\''; flush privileges;"
      rm /etc/mysql/conf.d/grant.cnf
      systemctl restart mysql'
    fi