# Temporal connectivity with MySQL

**URL:** <https://community.temporal.io/t/temporal-connectivity-with-mysql/5391>\
**Category:** Community Support\
**Tags:** mysql\
**Created:** [July 20, 2022, 9:44am UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391 "2022-07-20T09:44:39Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![sahir](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@sahir](https://community.temporal.io/u/sahir)\
**Post date:** [July 20, 2022, 9:44am UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/1 "2022-07-20T09:44:39Z")

</div>

Hi Team,  
I want to connect my existing mysql database into the temporal Instead of Cassandra. I configured the mysql credentials in values.mysql.yaml file like this

```auto
server:
  config:
    persistence:
      default:
        driver: "sql"

        sql:
          driver: "mysql"
          host: localhost
          port: 3306
          database: database name
          user: xyz
          password: xyz
          maxConns: 20
          maxConnLifetime: "1h"

      visibility:
        driver: "sql"

        sql:
          driver: "mysql"
          host: localhost
          port: 3306
          database: database name
          user: xyz
          password: xyz
          maxConns: 20
          maxConnLifetime: "1h"

cassandra:
  enabled: false

mysql:
  enabled: true

postgresql:
  enabled: false

schema:
  setup:
    enabled: false
  update:
    enabled: false

```

I enabled mysql into true and cassandra, elasticsearch, prometheus, grafana and postgresql into false and i try to install by using the command

```auto
helm install -f values/values.mysql.yaml temporaltest . --timeout 900s

```

also i tried with the another command

```auto
helm install -f values/values.mysql.yaml temporaltest \
  --set elasticsearch.enabled=false \
  --set server.config.persistence.default.sql.user=mysql_user \
  --set server.config.persistence.default.sql.password=mysql_password \
  --set server.config.persistence.visibility.sql.user=mysql_user \
  --set server.config.persistence.visibility.sql.password=mysql_password \
  --set server.config.persistence.default.sql.host=mysql_host \
  --set server.config.persistence.visibility.sql.host=mysql_host . --timeout 900s

```

By using the above commands the chart is deployed but all the pod is in crashloopbackoff and pending state.  
Can you please suggest some ideas to connect the existing mysql into the temporal.

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 20, 2022, 3:08pm UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/3 "2022-07-20T15:08:10Z")

</div>

Hi, where is your db running, locally on machine, docker or your k8s/minikube cluster?

---

<div class="post-metadata">

**Author:** ![sahir](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@sahir](https://community.temporal.io/u/sahir)\
**Post date:** [July 20, 2022, 3:46pm UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/4 "2022-07-20T15:46:29Z")

</div>

Hi @tihomir my DB is running locally

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 20, 2022, 9:40pm UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/5 "2022-07-20T21:40:58Z")

</div>

Depending what you are running on you would need to enable host access. I tested with minikube and was able to use [`host.minikube.internal`](https://minikube.sigs.k8s.io/docs/handbook/host-access/) as the sql host:

```auto
helm install -f values/values.mysql.yaml temporaltest \
  --set elasticsearch.enabled=false \
  --set prometheus.enabled=false \
  --set grafana.enabled=false \
  --set server.config.persistence.default.sql.user=myuser \
  --set server.config.persistence.default.sql.password=mypassword \
  --set server.config.persistence.visibility.sql.user=myuser \
  --set server.config.persistence.visibility.sql.password=mypassword \
  --set server.config.persistence.default.sql.host=host.minikube.internal \
  --set server.config.persistence.visibility.sql.host=host.minikube.internal . --timeout 900s

```

Just make sure that locally your mysql user has a non-blank password (if you use root by default its blank so make sure you set it to something) cause there seems to be a small issue with having blank password for sql in helm charts atm, investigating.

---

<div class="post-metadata">

**Author:** ![sahir](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@sahir](https://community.temporal.io/u/sahir)\
**Post date:** [July 21, 2022, 11:26am UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/6 "2022-07-21T11:26:35Z")

</div>

Hi @tihomir  
Thanks for your reply, I configured the MySQL DB in minikube cluster but when i try to install temporal-sql-tool it showing an error. Can you please suggest some ideas to configure the temporal-sql-tool.

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 21, 2022, 2:25pm UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/7 "2022-07-21T14:25:59Z")

</div>

Whats the error you are getting?  
Assume you cloned [temporal server repo](https://github.com/temporalio/temporal)  
and ran

`make install`

from it, right?

---

<div class="post-metadata">

**Author:** ![sahir](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@sahir](https://community.temporal.io/u/sahir)\
**Post date:** [July 22, 2022, 5:08am UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/8 "2022-07-22T05:08:28Z")

</div>

Hi @tihomir  
Yeah I clone the repo and run the command

```auto
export SQL_PLUGIN=mysql
export SQL_HOST=mysql_host
export SQL_PORT=3306
export SQL_USER=mysql_user
export SQL_PASSWORD=mysql_password

```

```auto
SQL_USER=$SQL_USER SQL_PASSWORD=$SQL_PASSWORD make install-schema-mysql

```

```auto
 Run `make

```

when I ran the install schema mysql command I facing error like this

```auto
$ SQL_USER=$SQL_USER SQL_PASSWORD=$SQL_PASSWORD make install-schema-mysql
process_begin: CreateProcess(NULL, go env GOBIN, ...) failed.
Makefile:48: pipe: No error
process_begin: CreateProcess(NULL, go env GOPATH, ...) failed.
Makefile:48: pipe: No error
process_begin: CreateProcess(NULL, go env GOPATH, ...) failed.
Makefile:69: pipe: Bad file descriptor
process_begin: CreateProcess(NULL, go env GOOS, ...) failed.
Makefile:409: pipe: Bad file descriptor
process_begin: CreateProcess(NULL, go env GOOS, ...) failed.
Makefile:410: pipe: Bad file descriptor
process_begin: CreateProcess(NULL, go env GOOS, ...) failed.
Makefile:201: pipe: No such file or directory
process_begin: CreateProcess(NULL, go env GOARCH, ...) failed.
Makefile:201: pipe: No such file or directory
Build temporal-sql-tool with CGO_ENABLED=0 for /...
CGO_ENABLED=0 go build -o temporal-sql-tool ./cmd/tools/sql
/usr/bin/sh: go: command not found
make: *** [Makefile:202: temporal-sql-tool] Error 127

```

I couldn’t able to install temporal-sql-tool

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 23, 2022, 2:58am UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/9 "2022-07-23T02:58:09Z")

</div>

Can you check that you have GOROOT system var on your system?  
`echo $GOROOT`

Can you compile all the tools by just running `make` ?

[`make install-schema-mysql`](https://github.com/temporalio/temporal/blob/master/Makefile#L357) requires temporal db user to exist and you would need to set `TEMPORAL_DB` and `VISIBILITY_DB` env vars before running it.

If you are able to just run make to build all tools you can follow the scripts in helm chart repo [here](https://github.com/temporalio/helm-charts#install-with-your-own-mysql).

Hope this helps.

---

<div class="post-metadata">

**Author:** ![sahir](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@sahir](https://community.temporal.io/u/sahir)\
**Post date:** [July 25, 2022, 5:25pm UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/10 "2022-07-25T17:25:18Z")

</div>

Hi @tihomir  
When I run the command make install-schema-mysql I’m facing the error like this.

```auto
Build temporal-sql-tool with CGO_ENABLED=0 for windows/amd64...
CGO_ENABLED=0 go build -o temporal-sql-tool ./cmd/tools/sql
error obtaining VCS status: exit status 0xc000007b
        Use -buildvcs=false to disable VCS stamping.
make: *** [Makefile:207: temporal-sql-tool] Error 1

```

I try with -buildvcs=false command also but the error is not resolved

---

<div class="post-metadata">

**Author:** ![sahir](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@sahir](https://community.temporal.io/u/sahir)\
**Post date:** [July 28, 2022, 7:33am UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/11 "2022-07-28T07:33:01Z")

</div>

Hi @tihomir MySQL connectivity issue is resolved now but when i try to deploy a chart using this command

```auto
helm install --set server.replicaCount=1 --set cassandra.config.cluster_size=1 --set prometheus.enabled=false --set grafana.enabled=false --set elasticsearch.enabled=false temporal-server . --timeout 15m 

```

I enabled Cassandra=false  
I enabled MySQL = true in values.yaml  
and configure the values.mysql.yaml and deployed using the above command but i got an error like this

```auto
Please specify cassandra port for default store

```

---

<div class="post-metadata">

**Author:** ![sahir](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@sahir](https://community.temporal.io/u/sahir)\
**Post date:** [July 28, 2022, 4:42pm UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/12 "2022-07-28T16:42:09Z")

</div>

Hi @tihomir  
Do we need cassandra to be enabled while installing Mysql ?  
Will Mysql spin into separate pod ?

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 31, 2022, 9:05pm UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/13 "2022-07-31T21:05:09Z")

</div>

> Do we need cassandra to be enabled while installing Mysql ?

No you should not need to have cassandra enabled as you are not using it. You can use value flag as shown in [previous reply](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/5) and use values\_mysql.yaml to overwrite defaults set in values.yaml.

> Will Mysql spin into separate pod ?

Should not, you mentioned you want to use local mysql right?

---

<div class="post-metadata">

**Author:** ![sahir](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@sahir](https://community.temporal.io/u/sahir)\
**Post date:** [August 12, 2022, 5:24am UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/14 "2022-08-12T05:24:24Z")

</div>

Thank you @tihomir

---

<div class="post-metadata">

**Author:** ![kaleby](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/kaleby/32/5198_2.png) [@kaleby](https://community.temporal.io/u/kaleby)\
**Post date:** [April 8, 2024, 9:36pm UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/15 "2024-04-08T21:36:17Z")

</div>

Having the same error `Please specify cassandra port for visibility store` here but I’m using a cloudsql proxy sidecar container so I’m trying to install temporal disabling Cassandra like this:

```auto
helm install -f values/values.cloudsqlproxy.yaml -n temporal \
    --set cassandra.enabled=false \
    --set prometheus.enabled=true \
    --set grafana.enabled=false \
    --set elasticsearch.enabled=true \
    temporal . --timeout 900s

```

How can I make that work?

---

<div class="post-metadata">

**Author:** ![Andrew\_Stevens](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/andrew_stevens/32/6514_2.png) [@Andrew\_Stevens](https://community.temporal.io/u/Andrew_Stevens)\
**Post date:** [December 16, 2024, 7:49pm UTC](https://community.temporal.io/t/temporal-connectivity-with-mysql/5391/16 "2024-12-16T19:49:41Z")

</div>

I know it’s a long time since this was posted, @kaleby, but this is still the top google search result for:  
`Please specify cassandra port for visibility store`

So I wanted to reply anyway. In my case, this was because I hadn’t set the driver to SQL for the visibility store in my values.yaml. I had set it for the default store, but missed doing it on the visibility store.
