Restoring to mariadb10.1 fails the first time, but succeeds when restoring again after recreating the database

I am upgrading from mariadb5.5 to 10.1. I'm trying to restore the dump file output from 5.5 to 10.1, but I'm suffering from the phenomenon that the first restore always fails, and the restore succeeds after deleting and recreating the database. The content of the error is

ERROR 1449 (HY000) at line 44811: The user specified as a definer ('batch'@'localhost') does not exist

But 'batch'@'localhost' does exist and indeed a second restore succeeds with the same dump file without adding the user. The commands I'm actually using are:

// in mariadb5.5
$ mysqldump -u root -p -x -h localhost -R --opt --quick databasename | gzip > /root/backup_db/databasename.sql.gz
$ mysqldump -u root -p -x -h localhost --allow-keywords mysql | gzip > /root/backup_db/mysql.sql.gz

// After installing mariadb10.1
$ mysql_secure_installation
$ mysql_upgrade -u root -p
$ mysql -u root -p -h localhost
# create database databasename;
# \q
// After decompressing the compressed dump file
$ mysql -u root -p -h localhost mysql < mysql.sql
$ mysql -u root -p -h localhost databasename< databasename.sql // always fails here

$ mysql -u root -p -h localhost
# drop database databasename;
# create database databasename;
# \q

$ mysql -u root -p -h localhost databasename< databasename.sql // success here

Please let me know if there are any possible causes or things to check. Thank you.

Thinking that net_buffer_length is insufficient,

net_buffer_length=1024000 

I tried to restore by changing to , but it failed. Max_allowed_packet at that time was

max_allowed_packet=100MB

Answer Answered by kosuke shinoda in this comment.

solved. After executing mysql_update between restoring mysql and restoring databasename, the error disappeared. It seems that FLUSH PRIVILEGES was necessary after restoring mysql. thank you very much.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.