Error while setting mySql as internal db

Hi want to change the internal database to mysql. I have setup mysql on my local and I have created the database grafana and the table sessions as per the user guide. Now I can connect to mysql successfully.

I changed the config in my grafana here -> conf/defaults.ini

[database]
# You can configure the database connection by specifying type, host, name, user and password
# as separate properties or as on string using the url property.

# Either "mysql", "postgres" or "sqlite3", it's your choice
type = mysql
host = 127.0.0.1:3306
name = grafana
user = root
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password =

url =

# Max conn setting default is 0 (mean not set)
max_idle_conn =
max_open_conn =

# For "postgres", use either "disable", "require" or "verify-full"
# For "mysql", use either "true", "false", or "skip-verify".
ssl_mode = false

ca_cert_path =
client_key_path =
client_cert_path =
server_cert_name =

#################################### Session #############################
[session]
# Either "memory", "file", "redis", "mysql", "postgres", "memcache", default is "file"
provider = mysql

I get the below error when I try to start my server -> ./bin/grafana-server

root@97733f17bb01:/Users/kmehta/workspace/src/github.com/grafana/grafana# ./bin/grafana-server
INFO[05-18|19:35:19] Starting Grafana                         logger=main version=4.3.0-pre1 commit=51a448d compiled=2017-05-05T19:41:13+0000
INFO[05-18|19:35:19] Config loaded from                       logger=settings file=/Users/kmehta/workspace/src/github.com/grafana/grafana/conf/defaults.ini
INFO[05-18|19:35:19] Path Home                                logger=settings path=/Users/kmehta/workspace/src/github.com/grafana/grafana
INFO[05-18|19:35:19] Path Data                                logger=settings path=/Users/kmehta/workspace/src/github.com/grafana/grafana/data
INFO[05-18|19:35:19] Path Logs                                logger=settings path=/Users/kmehta/workspace/src/github.com/grafana/grafana/data/log
INFO[05-18|19:35:19] Path Plugins                             logger=settings path=/Users/kmehta/workspace/src/github.com/grafana/grafana/data/plugins
INFO[05-18|19:35:19] Initializing DB                          logger=sqlstore dbtype=mysql
INFO[05-18|19:35:19] Starting DB migration                    logger=migrator
INFO[05-18|19:35:19] Executing migration                      logger=migrator id="copy data account to org"
INFO[05-18|19:35:19] Skipping migration condition not fulfilled logger=migrator id="copy data account to org"
INFO[05-18|19:35:19] Executing migration                      logger=migrator id="copy data account_user to org_user"
INFO[05-18|19:35:19] Skipping migration condition not fulfilled logger=migrator id="copy data account_user to org_user"
INFO[05-18|19:35:19] Starting plugin search                   logger=plugins
INFO[05-18|19:35:19] Initializing CleanUpService              logger=cleanup
INFO[05-18|19:35:19] Initializing Alerting                    logger=alerting.engine
panic: invalid DSN: missing the slash separating the database name

goroutine 1 [running]:
github.com/grafana/grafana/pkg/middleware.Sessioner(0x1a435c0, 0xfbf0a0, 0x118d078)
	/Users/kmehta/workspace/src/github.com/grafana/grafana/pkg/middleware/session.go:71 +0x2d5
github.com/grafana/grafana/pkg/api.(*HttpServer).newMacaron(0xc4202c11c0, 0x7f910543c0e0)
	/Users/kmehta/workspace/src/github.com/grafana/grafana/pkg/api/http_server.go:168 +0x680
github.com/grafana/grafana/pkg/api.(*HttpServer).Start(0xc4202c11c0, 0x7f9105440490, 0xc4202806c0, 0x1125b44, 0x7)
	/Users/kmehta/workspace/src/github.com/grafana/grafana/pkg/api/http_server.go:47 +0x94
main.(*GrafanaServerImpl).startHttpServer(0xc420280740)
	/Users/kmehta/workspace/src/github.com/grafana/grafana/pkg/cmd/grafana-server/server.go:79 +0x65
main.(*GrafanaServerImpl).Start(0xc420280740)
	/Users/kmehta/workspace/src/github.com/grafana/grafana/pkg/cmd/grafana-server/server.go:74 +0x29f
main.main()
	/Users/kmehta/workspace/src/github.com/grafana/grafana/pkg/cmd/grafana-server/main.go:88 +0x1bb

You need to set the provider_config item in the [session] block to root:<password>@tcp(127.0.0.1:3306)/grafana, to tell Grafana which database to use for sessions.

awesome. It works! Thanks!

1 Like