Restoring Backup From mysqldump does not Recreate All Views + Error 1449 + SQLState HY000 + The User Specified as a Definer does not Exist (Doc ID 1365866.1)

Last updated on NOVEMBER 22, 2011

Applies to:

MySQL Server - Version: 5.0 and later   [Release: 5.0 and later ]
MySQL Server - Version: 5.0 and later    [Release: 5.0 and later]
Information in this document applies to any platform.

Symptoms

When attempting to load the dump of all databases from mysqldump into a freshly installed MySQL instance, the following error occurs.

ERROR 1449 (HY000) at line 907: The user specified as a definer ('viewadmin'@'%') does not exist

In the above error message, the line number and username ('viewadmin'@'%') will depend on the actual dump being reloaded.

Reproducing the Issue

The issue can be reproduced at will with the following steps:
  1. Create the schema in the old installation

    mysql> CREATE DATABASE viewtest;
    Query OK, 1 row affected (0.01 sec)

    mysql> use viewtest;
    Database changed

    mysql> GRANT ALL ON viewtest.* TO 'viewadmin'@'%' IDENTIFIED BY 'some_password';
    Query OK, 0 rows affected (0.00 sec)

    mysql> CREATE DEFINER=`viewadmin`@`%` SQL SECURITY DEFINER VIEW v1 AS SELECT 1;
    Query OK, 0 rows affected (0.02 sec)

    mysql> CREATE DEFINER=`viewadmin`@`%` SQL SECURITY DEFINER VIEW v2 AS SELECT * FROM v1;
    Query OK, 0 rows affected (0.02 sec)

  2. Dump all databases from the old installation

    shell$ mysqldump -A >/tmp/mysqldump.sql

  3. Load the dump into the new installation

    shell$ mysql --show-warnings < /tmp/mysqldump.sql
    ERROR 1449 (HY000) at line 907: The user specified as a definer ('viewadmin'@'%') does not exist


Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms