I am trying to use MySQL database instead of default sqlite database for grafana. I am using AWS RDS service to create MySQL database and I have hosted my grafana on ECS.
I have given name to database is database-1.
I have followed the steps to make changes in grafana.ini file. where I have given database name and password and also provided endpoint for database.
While I am trying to run the grafana service on ecs I am getting following error message.
logger=migrator t=2023-03-29T07:07:10.83376018Z level=error msg=âalert migration failure: could not get migration logâ error=âfailed to check table existence: Error 1049: Unknown database âdatabase-1ââ
You just need to create mysql database and user for Grafana, then update Grafanaâs config file.
# Either "mysql", "postgres" or "sqlite3", it's your choice
type = mysql
host = mysql-host-where-my-db-is:3306
name = db_name
user = db_username
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password = MY-INSANE-STRONG-PASS
# For "postgres", use either "disable", "require" or "verify-full"
# For "mysql", use either "true", "false", or "skip-verify".
ssl_mode = disable
# Max idle conn setting default is 2
max_idle_conn = 2
If thatâs a clean new installation you should not see migration warnings and errors like this.
Also Error 1049: Unknown database âdatabase-1ââ means the database probably donât exist in the mysql server.
Check the mysql server DB. If youâre making a clean installation make sure the database have no tables.
Make sure the database name is the same as the one in the config. Note I wouldnât use - in the database name.
Try creating a new one: grafana_db
Create user/pass with permissios to that database.
Update grafana config and restart the service.
Try connecting to the mysql server via ssh console from Grafana host.
Please show us (copy and paste) the relevant section of the config file where
you specify the DB details (obscure the password) and show us the command you
are running which produces the error.