# Error while setting mySql as internal db

**URL:** <https://community.grafana.com/t/error-while-setting-mysql-as-internal-db/997>\
**Category:** Configuration\
**Tags:** mysql\
**Created:** [May 18, 2017, 7:54pm UTC](https://community.grafana.com/t/error-while-setting-mysql-as-internal-db/997 "2017-05-18T19:54:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![komal](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/komal/32/198_2.png) [@komal](https://community.grafana.com/u/komal)\
**Post date:** [May 18, 2017, 7:54pm UTC](https://community.grafana.com/t/error-while-setting-mysql-as-internal-db/997/1 "2017-05-18T19:54:40Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![dcech](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/dcech/32/49_2.png) [@dcech](https://community.grafana.com/u/dcech)\
**Post date:** [May 18, 2017, 7:58pm UTC](https://community.grafana.com/t/error-while-setting-mysql-as-internal-db/997/2 "2017-05-18T19:58:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![komal](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/komal/32/198_2.png) [@komal](https://community.grafana.com/u/komal)\
**Post date:** [May 18, 2017, 8:06pm UTC](https://community.grafana.com/t/error-while-setting-mysql-as-internal-db/997/3 "2017-05-18T20:06:19Z")

</div>

awesome. It works! Thanks!

---

<div class="post-metadata">

**Author:** ![anon80964540](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@anon80964540](https://community.grafana.com/u/anon80964540)\
**Post date:** [January 13, 2021, 4:02pm UTC](https://community.grafana.com/t/error-while-setting-mysql-as-internal-db/997/4 "2021-01-13T16:02:35Z")

</div>

Closed on January 13, 2021, 4:02pm UTC


