database-migrator icon indicating copy to clipboard operation
database-migrator copied to clipboard

Timezone identifiers exported on come columns causing error on mysql/mariadb import.

Open judilsteve opened this issue 2 years ago • 3 comments

I'm using this script to migrate a Grafana 6.6.1 installation from SQLite to MariaDB. When I attempt to import the dump with the mysql client I get the following error:

ERROR 1292 (22007) at line 368: Incorrect datetime value: '2022-07-12 08:16:10.96344947+00:00' for column `grafana`.`alert`.`new_state_date` at row 1

It looks like this column (and potentially others) has been set up to print timezone info when selected, making the string literals incompatible with the mysql/mariadb DATETIME type.

A simple find/replace of +00:00 with an empty string fixed this for my case, but it might be worth integrating this into the script or at least calling it out in the README.

judilsteve avatar Nov 25 '22 05:11 judilsteve

I had the same problem when I'm using this script to migrate a Grafana 9.3.2 installation from SQLite to MySQL 。

A simple find/replace of +00:00( and +08:00) with an empty string fixed this for my case。It work ok。

Write it down。

Thanks judilsteve 。

erdong avatar Feb 06 '23 10:02 erdong

For folks who visit this later and want a handy command, this can be useful: sed -i 's/\+00:00//g' db_dump.sql

kiraniyer8 avatar Jul 28 '23 06:07 kiraniyer8

Thanks for this, I was trying to understand why it was failing, and this filled in the gap of knowledge for me. Removing the additional -04:00 in my case resolved the issue.

TheAlienKnight avatar Sep 20 '24 16:09 TheAlienKnight