Migrate sqlite to mysql

Hi
we have a grafana that is using SQLite as the backend and now it is getting very big so we want to migrate the data to MySQL, is there any safe way to perform this?

Hi @nesabian,

The Grafana team maintains a handy script for migrating grafana configuration data from SQLite to MySQL.

check this out:

You might also like this long thread on the same topic:

1 Like

Hi,

I’m currently working on setting up highly available Grafana servers for our organization. As part of this process, we are transitioning the Grafana database to MySQL, hosted externally. However, I’m encountering an issue when attempting to migrate the data using the Grafana data migrator script available online.

Specifically, I’m seeing the following error when running sqlitedump.sh:


> awk: escape.awk: line 4: syntax error at or near ,

I am following the exact steps provided by this GitHub repository. Despite reviewing various documents and resources, all point back to this repository, but none address the error I am facing.

Could someone please assist me in resolving this issue or suggest an alternative approach for migrating the Grafana data to MySQL? Your guidance would be greatly appreciated.

Thank you.

https://github.com/grafana/database-migrator

open escape.awk and look at line 4

Hi, yes I did that. Not sure what is wrong with this script

this script is used to backtick tables and columns for each insert statement

/^INSERT/ {
# Match columns definition
match($0, /^INSERT INTO (.+)(([^)]+)) VALUES((.+));$/, matches)

table = matches[1]
middle = matches[2]
values = matches[3]

# strip all quotes from columns and create an array of column
# names
gsub(/"/, "", middle)
split(middle, columns, ",")

sep = ""
cols = ""
for(i in columns) {
    cols = cols sep "`" columns[i] "`"
    sep = ","
}

printf("INSERT INTO `%s` (%s) VALUES (%s);\n", table, cols, values)

}

which one is line 4?

Hi ,

When I bring up grafana services post connecting to mysql I can see that not all tables are getting created which were there in sqllite3, due to which I cannot migrate the data any suggestions please?