database-migrator
database-migrator copied to clipboard
Timezone identifiers exported on come columns causing error on mysql/mariadb import.
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.
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 。
For folks who visit this later and want a handy command, this can be useful:
sed -i 's/\+00:00//g' db_dump.sql
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.