Grafana database with mysql

Hi guys,

I have a tree node mariadb cluster and I want to use this database for grafana. I convert the sqlite3db to mysql with https://www.rebasedata.com and I configure the /etc/grafana/grafana.ini but right now I get a error like this:

t=2021-08-10T12:40:36+0000 lvl=crit msg=“alert migration failure: could not get migration log” logger=migrator error=“failed to check table existence: Error 1045: Access denied for user ‘xx’@‘xx’ (using password: YES)”

And I try this github code and this forum page…

It’s not connection error because I try to connect mysql like this, I can connect.

mysql -h XX -u XX -p

What am I doing wrong?

edit:
My Grafana version: 8.0.6
My MariaDB version: 10.3.30

And this

I get this error

ERROR 1146 (42S02) at line 1: Table ‘grafana_serverdb3.alert’ doesn’t exist

Today I try “Database Migration Toolkit” from dbsoft.com and db migration is ok. There is a 3 error but I fix it.

Getting ‘alert_instance’ table structure …
Creating table ‘alert_instance’ …
Create table ‘alert_instance’ failed!
Code: 1170, Msg: ERROR 1170: BLOB/TEXT column ‘rule_uid’ used in key specification without a key
length
CREATE TABLE alert_instance (rule_org_id INT NOT NULL AUTO_INCREMENT COMMENT
‘TRIAL’,
rule_uid LONGTEXT NOT NULL COMMENT ‘TRIAL’,
labels LONGTEXT NOT NULL COMMENT ‘TRIAL’,
labels_hash LONGTEXT NOT NULL COMMENT ‘TRIAL’,
current_state LONGTEXT NOT NULL COMMENT ‘TRIAL’,
current_state_since INT NOT NULL COMMENT ‘TRIAL’,
last_eval_time INT NOT NULL COMMENT ‘TRIAL’,
current_state_end INT NOT NULL DEFAULT 0 COMMENT ‘TRIAL’,
trial831 CHAR(1) COMMENT ‘TRIAL’,
PRIMARY KEY(rule_org_id,rule_uid,labels_hash)) ENGINE=InnoDB COMMENT=‘TRIAL’

Getting ‘cache_data’ table structure …
Creating table ‘cache_data’ …
Create table ‘cache_data’ failed!
Code: 1170, Msg: ERROR 1170: BLOB/TEXT column ‘cache_key’ used in key specification without a
key length
CREATE TABLE cache_data (cache_key LONGTEXT NOT NULL COMMENT ‘TRIAL’,
data LONGBLOB NOT NULL COMMENT ‘TRIAL’,
expires INT NOT NULL COMMENT ‘TRIAL’,
created_at INT NOT NULL COMMENT ‘TRIAL’,
trial844 CHAR(1) COMMENT ‘TRIAL’,
PRIMARY KEY(cache_key)) ENGINE=InnoDB COMMENT=‘TRIAL’

Getting ‘session’ table structure …
Creating table ‘session’ …
Create table ‘session’ failed!
Code: 1170, Msg: ERROR 1170: BLOB/TEXT column ‘key’ used in key specification without a key
length
CREATE TABLE session (key LONGTEXT NOT NULL COMMENT ‘TRIAL’,
data LONGBLOB NOT NULL COMMENT ‘TRIAL’,
expiry INT NOT NULL COMMENT ‘TRIAL’,
trial890 CHAR(1) COMMENT ‘TRIAL’,
PRIMARY KEY(key)) ENGINE=InnoDB COMMENT=‘TRIAL’

I change SQL command to this

CREATE TABLE alert_instance (
rule_org_id INT NOT NULL AUTO_INCREMENT,
rule_uid VARCHAR(255) NOT NULL,
labels VARCHAR(255) NOT NULL,
labels_hash VARCHAR(255) NOT NULL ,
current_state VARCHAR(255) NOT NULL,
current_state_since INT NOT NULL,
last_eval_time INT NOT NULL,
current_state_end INT NOT NULL DEFAULT 0,
trial831 CHAR(1),
PRIMARY KEY(rule_org_id,rule_uid,labels_hash)) ENGINE=InnoDB;

CREATE TABLE cache_data (
cache_key VARCHAR(255) NOT NULL,
data LONGBLOB NOT NULL,
expires INT NOT NULL,
created_at INT NOT NULL,
trial844 CHAR(1),
PRIMARY KEY(cache_key)) ENGINE=InnoDB;

CREATE TABLE session (
key VARCHAR(255) NOT NULL,
data LONGBLOB NOT NULL,
expiry INT NOT NULL,
trial890 CHAR(1),
PRIMARY KEY(key)) ENGINE=InnoDB;

Database is ok but I still see this error in grafana logs.

t=2021-08-11T08:35:32+0000 lvl=crit msg=“alert migration failure: could not get migration log” logger=migrator error=“failed to check table existence: Error 1045: Access denied for user ‘xx’@‘xx’ (using password: YES)”

Any idea?

It’s my fault.

I fix the /etc/grafana/grafana.ini config like that.

type = mysql
host = host_ip:3306
name = database_name
user = database_user
password = “”“database_password”""

I must use “”" because my passsword include # ; and @ char.

can u put multiple mysql IP addresses in the same config.