How to Take mysqldump with Generated Column

mariadb-10.3mysql-5.7mysqldump

I am getting below error while importing the dump,

ERROR 3105 (HY000) at line 82: The value specified for generated
column 'column_name' in table 'table_name' is not allowed.

When I describe the table with error, there are some generated columns in it.

option_type | varchar(45) | YES | MUL | NULL | VIRTUAL
GENERATED

What is the correct command to use when taking mysql dump for the database contains generated column?

MySQL server source and destination version:

mysqld Ver 5.7.26 for Linux on x86_64 (MySQL Community Server (GPL))

MariaDB mysqldump CLI version:

mysqldump Ver 10.17 Distrib 10.3.12-MariaDB, for Linux (x86_64)

Best Answer

This is a problem when using mysqldump from MariaDB with virtual generated columns. MariaDB's mysqldump apparently dumps the generated values, but MySQL only accepts DEFAULT as value for a virtual generated column.

It seems like you need to use MySQL's mysqldump to correctly dump and restore virtual generated columns on a MySQL server.