Im trying to do an initial transfer of my data to a replica server by running this command:
sudo mysqldump -f -u root -pPassword --opt mydb | mysql --host=replica01 -C mydb -u restore -pPassword
It copies most of the data, but stops on one of the functions i've created with this error:
ERROR 1305 (42000) at line 3750: FUNCTION mydb.myFunction does not exist mysqldump: Got errno 32 on write
I have both procedures and functions in my database. Some procedures use functions in them. Is that what is causing this? In that case, what can i do to ignore these errors?
-
1Any functions that are used need to be defined before they are used. Try editing the dump and shift them.Rohit Gupta– Rohit Gupta2023年01月13日 13:42:00 +00:00Commented Jan 13, 2023 at 13:42
1 Answer 1
You should try doing mysqldump without the stored procedures
In your case, it would be
sudo mysqldump -f -u root -pPassword --skip-routines -opt mydb | mysql --host=replica01 -C mydb -u restore -pPassword
You should also dump the stored procedures into a text file
See my old post Dump only the Stored Procedures in MySQL
In your case it would be
mysqldump -f -u root -pPassword --routines --skip-triggers --no-data --no-create-info -opt mydb > mydb_sp.sql
Have a look at the file
less mydb_sp.sql
then import the stored procedures like this
mysql --host=replica01 -C mydb -u restore -pPassword < mydb_sp.sql
-
Turned out procedures were skipped, but there was a view that utilized one of them. Marked as answer as it put me in the right track. Thank you!jared– jared2023年01月16日 08:21:18 +00:00Commented Jan 16, 2023 at 8:21