Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-13486

Make mysql_install_db create a real ''@'%' anonymous account for the test database

    Details

      Description

      mysql_install_db only partially creates a ''@'%' user when setting up the test database. This causes errors that are difficult to interpret when someone tries to actually create a ''@'%' user. For example:

      MariaDB [(none)]> SELECT VERSION();
      +-----------------+
      | VERSION()       |
      +-----------------+
      | 10.1.25-MariaDB |
      +-----------------+
      1 row in set (0.00 sec)
       
      MariaDB [(none)]> SELECT User, Host FROM mysql.user WHERE User='';
      Empty set (0.00 sec)
       
      MariaDB [(none)]> CREATE USER ''@'%';
      ERROR 1396 (HY000): Operation CREATE USER failed for ''@'%'
      

      The root cause of the problem is that scripts/mysql_test_db.sql inserts some rows into mysql.db for the ''@'%' user, but it does not also insert a row into mysql.user for the user:

      https://github.com/MariaDB/server/blob/4abb8216a054e14afbeb81e8529e02bab6fa14ac/scripts/mysql_test_db.sql

      We should probably fix scripts/mysql_test_db.sql, so that it creates a row in mysql.user for the ''@'%' user.

      For now, this can be worked around by deleting the row in the mysql.db table and then executing FLUSH PRIVILEGES. For example:

      DELETE FROM mysql.db WHERE User='' AND Host='%';
      FLUSH PRIVILEGES;
      

      And then the account can be created:

      MariaDB [(none)]> CREATE USER ''@'%';
      Query OK, 0 rows affected (0.01 sec)
      

      This is documented here:

      https://mariadb.com/kb/en/library/create-user/#fixing-a-legacy-default-anonymous-account

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                GeoffMontee Geoff Montee
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: