{
    "componentChunkName": "component---src-pages-blog-markdown-remark-fields-slug-js",
    "path": "/blog/connect-supertokens-to-database",
    "result": {"data":{"markdownRemark":{"html":"<p>This blog will take you through connecting the SuperTokens core service with a MySQL or a PostgreSQL database with and without Docker.</p>\n<blockquote>\n<p>This is only applicable if you are self-hosting the SuperTokens core service.</p>\n</blockquote>\n<p>There are several methods for how you might want to run SuperTokens along with a database. In this blog, we will cover:</p>\n<ul>\n<li>\n<ol>\n<li>Running with MySQL:</li>\n</ol>\n<ul>\n<li><a href=\"#running-supertokens-and-mysql-without-docker\">a) Running SuperTokens and MySQL without docker</a></li>\n<li><a href=\"#running-supertokens-with-docker-and-mysql-without-docker\">b) Running SuperTokens with Docker and MySQL without docker</a></li>\n<li><a href=\"#running-supertokens-without-docker-and-mysql-with-docker\">c) Running SuperTokens without Docker and MySQL with docker</a></li>\n<li><a href=\"#running-supertokens-and-mysql-with-docker-without-docker-compose\">d) Running SuperTokens and MySQL with docker, but without docker-compose</a></li>\n<li><a href=\"#running-supertokens-and-mysql-with-docker-with-docker-compose\">e) Running SuperTokens and MySQL with docker, with docker-compose</a></li>\n</ul>\n</li>\n<li>\n<ol start=\"2\">\n<li>Running with PostgreSQL:</li>\n</ol>\n<ul>\n<li><a href=\"#running-supertokens-and-postgresql-without-docker\">a) Running SuperTokens and PostgreSQL without docker</a></li>\n<li><a href=\"#running-supertokens-with-docker-and-postgresql-without-docker\">b) Running SuperTokens with Docker and PostgreSQL without docker</a></li>\n<li><a href=\"#running-supertokens-without-docker-and-postgresql-with-docker\">c) Running SuperTokens without Docker and PostgreSQL with docker</a></li>\n<li><a href=\"#running-supertokens-and-postgresql-with-docker-without-docker-compose\">d) Running SuperTokens and PostgreSQL with docker, but without docker-compose</a></li>\n<li><a href=\"#running-supertokens-and-postgresql-with-docker-with-docker-compose\">e) Running SuperTokens and PostgreSQL with docker, with docker-compose</a></li>\n</ul>\n</li>\n</ul>\n<p>Please feel free to navigate to the correct section based on your setup. In each section, we will be linking to the SuperTokens documentation wherever applicable so that this blog is not very lengthy.</p>\n<blockquote>\n<p>All the sections below assume that you will be using a Linux based operating system. For Windows, the syntax for some of the steps might be different, but the overall steps that need to be performed will be the same.</p>\n</blockquote>\n<h2 id=\"a-namerunning-supertokens-and-mysql-without-docker-href-1a-running-supertokens-and-mysql-without-docker-a\" style=\"position:relative;\"><a href=\"#a-namerunning-supertokens-and-mysql-without-docker-href-1a-running-supertokens-and-mysql-without-docker-a\" aria-label=\"a namerunning supertokens and mysql without docker href 1a running supertokens and mysql without docker a permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><a name=\"running-supertokens-and-mysql-without-docker\" href=\"\"> 1a) Running SuperTokens and MySQL without docker </a></h2>\n<ul>\n<li>\n<p>Install SuperTokens on your local machine by following the <a href=\"https://supertokens.com/docs/thirdpartyemailpassword/quick-setup/core/without-docker\" target=\"_blank\" rel=\"nofollow\">self-hosted, without docker, instructions in the SuperTokens’ documentation</a>.</p>\n</li>\n<li>\n<p>Connect to the MySQL server on your local machine and create a database for SuperTokens to write to:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"26141666470712234000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`create database supertokens;`, `26141666470712234000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">create</span> <span class=\"token keyword\">database</span> supertokens<span class=\"token punctuation\">;</span></code></pre></div>\n<p>If you already have a database for your application and want SuperTokens to create tables in that, you can skip this step.</p>\n</li>\n<li>\n<p>Create a MySQL user that has full access to the database created in the previous step. This user will be used by SuperTokens to create and write to the database tables:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"14123750749439967000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`CREATE USER 'supertokens_user'@'localhost' IDENTIFIED BY 'somePassword';`, `14123750749439967000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">CREATE</span> <span class=\"token keyword\">USER</span> <span class=\"token string\">'supertokens_user'</span><span class=\"token variable\">@'localhost'</span> IDENTIFIED <span class=\"token keyword\">BY</span> <span class=\"token string\">'somePassword'</span><span class=\"token punctuation\">;</span></code></pre></div>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"71594891769252360000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`GRANT ALL ON supertokens.* TO 'supertokens_user'@'localhost';`, `71594891769252360000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">GRANT</span> <span class=\"token keyword\">ALL</span> <span class=\"token keyword\">ON</span> supertokens<span class=\"token punctuation\">.</span><span class=\"token operator\">*</span> <span class=\"token keyword\">TO</span> <span class=\"token string\">'supertokens_user'</span><span class=\"token variable\">@'localhost'</span><span class=\"token punctuation\">;</span></code></pre></div>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"12893446645803008000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`FLUSH PRIVILEGES;`, `12893446645803008000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\">FLUSH <span class=\"token keyword\">PRIVILEGES</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Notice that we only allow this user to work via <code class=\"language-text\">'localhost'</code>. This would only work if the SuperTokens core is running locally as well. If you are running the core in a different location, then you would need to replace <code class=\"language-text\">'localhost'</code> in the above with <code class=\"language-text\">'%'</code>.</p>\n</li>\n<li>\n<p>Edit the SuperTokens <code class=\"language-text\">config.yaml</code> file (located in <code class=\"language-text\">/usr/lib/supertokens/config.yaml</code>) to add the following config:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"73783769210252870000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`mysql_connection_uri: &quot;mysql://supertokens_user:somePassword@localhost:3306/supertokens&quot;`, `73783769210252870000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">mysql_connection_uri</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"mysql://supertokens_user:somePassword@localhost:3306/supertokens\"</span></code></pre></div>\n<blockquote>\n<p>Make sure that you put in the right values for the user, password, database name and location of your MySQL instance in the above connection uri string.</p>\n</blockquote>\n</li>\n<li>\n<p>Run SuperTokens by running <code class=\"language-text\">supertokens start</code> on your terminal:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"4218430406750961700\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`supertokens start\n\nLoading storage layer.\nLoading MySQL config.\n...\nStarted SuperTokens on localhost:3567 with PID: ...`, `4218430406750961700`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">supertokens start\n\nLoading storage layer.\nLoading MySQL config.\n<span class=\"token punctuation\">..</span>.\nStarted SuperTokens on localhost:3567 with PID: <span class=\"token punctuation\">..</span>.</code></pre></div>\n</li>\n<li>\n<p>Verify that it is setup correctly by querying the core service:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"59908797566451840000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`curl http://localhost:3567/hello`, `59908797566451840000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">curl</span> http://localhost:3567/hello</code></pre></div>\n<p>If you get back a <code class=\"language-text\">Hello</code> reply, the core setup is done!</p>\n</li>\n</ul>\n<h2 id=\"a-namerunning-supertokens-with-docker-and-mysql-without-docker-href-1b-running-supertokens-with-docker-and-mysql-without-docker-a\" style=\"position:relative;\"><a href=\"#a-namerunning-supertokens-with-docker-and-mysql-without-docker-href-1b-running-supertokens-with-docker-and-mysql-without-docker-a\" aria-label=\"a namerunning supertokens with docker and mysql without docker href 1b running supertokens with docker and mysql without docker a permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><a name=\"running-supertokens-with-docker-and-mysql-without-docker\" href=\"\"> 1b) Running SuperTokens with Docker and MySQL without docker </a></h2>\n<p>For this setup to work, we must connect SuperTokens and MySQL via the host machine’s network. For this, we will have to expose the MySQL db to the local IP.</p>\n<ul>\n<li>\n<p>Start by pulling the SuperTokens docker image that is compatible with MySQL:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"17398163634611218000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker pull registry.supertokens.io/supertokens/supertokens-mysql`, `17398163634611218000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> pull registry.supertokens.io/supertokens/supertokens-mysql</code></pre></div>\n</li>\n<li>\n<p>Expose MySQL server to all network interfaces on your machine. To do this, edit the <code class=\"language-text\">my.cnf</code> file (MySQL config file) to include:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">bind-address = 0.0.0.0</code></pre></div>\n<p>Be sure to restart your MySQL server after saving the file.</p>\n</li>\n<li>\n<p>Connect to the MySQL server on your local machine and create a database for SuperTokens to write to:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"29817986186027803000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`create database supertokens;`, `29817986186027803000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">create</span> <span class=\"token keyword\">database</span> supertokens<span class=\"token punctuation\">;</span></code></pre></div>\n<p>If you already have a database for your application and want SuperTokens to create tables in that, you can skip this step.</p>\n</li>\n<li>\n<p>Create a MySQL user that has full access to the database created in the previous step. This user will be used by SuperTokens to create and write to the database tables:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"94342751119219640000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`CREATE USER 'supertokens_user'@'%' IDENTIFIED BY 'somePassword';`, `94342751119219640000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">CREATE</span> <span class=\"token keyword\">USER</span> <span class=\"token string\">'supertokens_user'</span><span class=\"token variable\">@'%'</span> IDENTIFIED <span class=\"token keyword\">BY</span> <span class=\"token string\">'somePassword'</span><span class=\"token punctuation\">;</span></code></pre></div>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"61603046972145310000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`GRANT ALL ON supertokens.* TO 'supertokens_user'@'%';`, `61603046972145310000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">GRANT</span> <span class=\"token keyword\">ALL</span> <span class=\"token keyword\">ON</span> supertokens<span class=\"token punctuation\">.</span><span class=\"token operator\">*</span> <span class=\"token keyword\">TO</span> <span class=\"token string\">'supertokens_user'</span><span class=\"token variable\">@'%'</span><span class=\"token punctuation\">;</span></code></pre></div>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"41030419116190810000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`FLUSH PRIVILEGES;`, `41030419116190810000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\">FLUSH <span class=\"token keyword\">PRIVILEGES</span><span class=\"token punctuation\">;</span></code></pre></div>\n</li>\n<li>\n<p>Run the SuperTokens docker image with the env var specifying the MySQL connection URI:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"60659079996626140000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker run \\\n  -p 3567:3567 \\\n  --network=host \\\n  -e MYSQL_CONNECTION_URI=&quot;mysql://supertokens_user:somePassword@192.168.1.1:3306/supertokens&quot; \\\n  -d registry.supertokens.io/supertokens/supertokens-mysql`, `60659079996626140000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> run <span class=\"token punctuation\">\\</span>\n  -p <span class=\"token number\">3567</span>:3567 <span class=\"token punctuation\">\\</span>\n  --network<span class=\"token operator\">=</span>host <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">MYSQL_CONNECTION_URI</span><span class=\"token operator\">=</span><span class=\"token string\">\"mysql://supertokens_user:somePassword@192.168.1.1:3306/supertokens\"</span> <span class=\"token punctuation\">\\</span>\n  -d registry.supertokens.io/supertokens/supertokens-mysql</code></pre></div>\n<blockquote>\n<p>Be sure to replace <code class=\"language-text\">192.168.1.1</code> with the correct IP of your system.</p>\n</blockquote>\n<p>This will start the docker image in the background. You can find it by running:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">docker ps</code></pre></div>\n<p>If you want to run it in the foreground, you can remove the <code class=\"language-text\">-d</code> option from the <code class=\"language-text\">docker run</code> command.</p>\n</li>\n<li>\n<p>Verify that it is setup correctly by querying the core service:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"21993193498421883000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`curl http://localhost:3567/hello`, `21993193498421883000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">curl</span> http://localhost:3567/hello</code></pre></div>\n<p>If you get back a <code class=\"language-text\">Hello</code> reply, the core setup is done!</p>\n</li>\n</ul>\n<h2 id=\"a-namerunning-supertokens-without-docker-and-mysql-with-docker-href-1c-running-supertokens-without-docker-and-mysql-with-dockera\" style=\"position:relative;\"><a href=\"#a-namerunning-supertokens-without-docker-and-mysql-with-docker-href-1c-running-supertokens-without-docker-and-mysql-with-dockera\" aria-label=\"a namerunning supertokens without docker and mysql with docker href 1c running supertokens without docker and mysql with dockera permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><a name=\"running-supertokens-without-docker-and-mysql-with-docker\" href=\"\"> 1c) Running SuperTokens without Docker and MySQL with docker</a></h2>\n<ul>\n<li>\n<p>Install SuperTokens on your local machine by following the <a href=\"https://supertokens.com/docs/thirdpartyemailpassword/quick-setup/core/without-docker\" target=\"_blank\" rel=\"nofollow\">self-hosted, without docker, instructions in the SuperTokens’ documentation</a>.</p>\n</li>\n<li>\n<p>Start the MySQL docker container:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"14121872518857814000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker run \\\n  -e MYSQL_ROOT_PASSWORD=root \\\n  -e MYSQL_USER=supertokens_user \\\n  -e MYSQL_PASSWORD=somePassword \\\n  -e MYSQL_DATABASE=supertokens \\\n  --network=host \\\n  -p 3306:3306 \\\n  -d mysql`, `14121872518857814000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> run <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">MYSQL_ROOT_PASSWORD</span><span class=\"token operator\">=</span>root <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">MYSQL_USER</span><span class=\"token operator\">=</span>supertokens_user <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">MYSQL_PASSWORD</span><span class=\"token operator\">=</span>somePassword <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">MYSQL_DATABASE</span><span class=\"token operator\">=</span>supertokens <span class=\"token punctuation\">\\</span>\n  --network<span class=\"token operator\">=</span>host <span class=\"token punctuation\">\\</span>\n  -p <span class=\"token number\">3306</span>:3306 <span class=\"token punctuation\">\\</span>\n  -d mysql</code></pre></div>\n<p>The above will start the mysql db with a new database called <code class=\"language-text\">supertokens</code>. SuperTokens core will store the data in this database. If instead, you want the data to be stored in an existing db, please provide that db’s name instead.</p>\n</li>\n<li>\n<p>Edit the SuperTokens <code class=\"language-text\">config.yaml</code> file (located in <code class=\"language-text\">/usr/lib/supertokens/config.yaml</code>) to add the following config:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"79397330766783400000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`mysql_connection_uri: &quot;mysql://supertokens_user:somePassword@localhost:3306/supertokens&quot;`, `79397330766783400000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">mysql_connection_uri</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"mysql://supertokens_user:somePassword@localhost:3306/supertokens\"</span></code></pre></div>\n<blockquote>\n<p>Make sure that you put in the right values for the user, password, database name and location of your MySQL instance in the above connection uri string.</p>\n</blockquote>\n</li>\n<li>\n<p>Run SuperTokens by running <code class=\"language-text\">supertokens start</code> on your terminal:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"41040391031026614000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`supertokens start\n\nLoading storage layer.\nLoading MySQL config.\n...\nStarted SuperTokens on localhost:3567 with PID: ...`, `41040391031026614000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">supertokens start\n\nLoading storage layer.\nLoading MySQL config.\n<span class=\"token punctuation\">..</span>.\nStarted SuperTokens on localhost:3567 with PID: <span class=\"token punctuation\">..</span>.</code></pre></div>\n</li>\n<li>\n<p>Verify that it is setup correctly by querying the core service:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"29727815757329010000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`curl http://localhost:3567/hello`, `29727815757329010000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">curl</span> http://localhost:3567/hello</code></pre></div>\n<p>If you get back a <code class=\"language-text\">Hello</code> reply, the core setup is done!</p>\n</li>\n</ul>\n<h2 id=\"a-namerunning-supertokens-and-mysql-with-docker-without-docker-compose-href-1d-running-supertokens-and-mysql-with-docker-but-without-docker-composea\" style=\"position:relative;\"><a href=\"#a-namerunning-supertokens-and-mysql-with-docker-without-docker-compose-href-1d-running-supertokens-and-mysql-with-docker-but-without-docker-composea\" aria-label=\"a namerunning supertokens and mysql with docker without docker compose href 1d running supertokens and mysql with docker but without docker composea permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><a name=\"running-supertokens-and-mysql-with-docker-without-docker-compose\" href=\"\"> 1d) Running SuperTokens and MySQL with docker, but without docker-compose</a></h2>\n<ul>\n<li>\n<p>Start by pulling the SuperTokens docker image that is compatible with MySQL:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"25263946021499728000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker pull registry.supertokens.io/supertokens/supertokens-mysql`, `25263946021499728000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> pull registry.supertokens.io/supertokens/supertokens-mysql</code></pre></div>\n</li>\n<li>\n<p>Start the MySQL docker container:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"97565769657766080000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker run \\\n  -e MYSQL_ROOT_PASSWORD=root \\\n  -e MYSQL_USER=supertokens_user \\\n  -e MYSQL_PASSWORD=somePassword \\\n  -e MYSQL_DATABASE=supertokens \\\n  --network=host \\\n  -p 3306:3306 \\\n  -d mysql`, `97565769657766080000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> run <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">MYSQL_ROOT_PASSWORD</span><span class=\"token operator\">=</span>root <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">MYSQL_USER</span><span class=\"token operator\">=</span>supertokens_user <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">MYSQL_PASSWORD</span><span class=\"token operator\">=</span>somePassword <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">MYSQL_DATABASE</span><span class=\"token operator\">=</span>supertokens <span class=\"token punctuation\">\\</span>\n  --network<span class=\"token operator\">=</span>host <span class=\"token punctuation\">\\</span>\n  -p <span class=\"token number\">3306</span>:3306 <span class=\"token punctuation\">\\</span>\n  -d mysql</code></pre></div>\n<p>The above will start the mysql db with a new database called <code class=\"language-text\">supertokens</code>. SuperTokens core will store the data in this database. If instead, you want the data to be stored in an existing db, please provide that db’s name instead.</p>\n</li>\n<li>\n<p>Run the SuperTokens docker image with the env var specifying the MySQL connection URI:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"21023494597807747000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker run \\\n  -p 3567:3567 \\\n  --network=host \\\n  -e MYSQL_CONNECTION_URI=&quot;mysql://supertokens_user:somePassword@192.168.1.1:3306/supertokens&quot; \\\n  -d registry.supertokens.io/supertokens/supertokens-mysql`, `21023494597807747000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> run <span class=\"token punctuation\">\\</span>\n  -p <span class=\"token number\">3567</span>:3567 <span class=\"token punctuation\">\\</span>\n  --network<span class=\"token operator\">=</span>host <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">MYSQL_CONNECTION_URI</span><span class=\"token operator\">=</span><span class=\"token string\">\"mysql://supertokens_user:somePassword@192.168.1.1:3306/supertokens\"</span> <span class=\"token punctuation\">\\</span>\n  -d registry.supertokens.io/supertokens/supertokens-mysql</code></pre></div>\n<blockquote>\n<p>Be sure to replace <code class=\"language-text\">192.168.1.1</code> with the correct IP of your system.</p>\n</blockquote>\n<p>This will start the docker image in the background. You can find it by running:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">docker ps</code></pre></div>\n<p>If you want to run it in the foreground, you can remove the <code class=\"language-text\">-d</code> option from the <code class=\"language-text\">docker run</code> command.</p>\n</li>\n<li>\n<p>Verify that it is setup correctly by querying the core service:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"42074056324878290000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`curl http://localhost:3567/hello`, `42074056324878290000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">curl</span> http://localhost:3567/hello</code></pre></div>\n<p>If you get back a <code class=\"language-text\">Hello</code> reply, the core setup is done!</p>\n</li>\n</ul>\n<h2 id=\"a-namerunning-supertokens-and-mysql-with-docker-with-docker-compose-href-1e-running-supertokens-and-mysql-with-docker-with-docker-compose-a\" style=\"position:relative;\"><a href=\"#a-namerunning-supertokens-and-mysql-with-docker-with-docker-compose-href-1e-running-supertokens-and-mysql-with-docker-with-docker-compose-a\" aria-label=\"a namerunning supertokens and mysql with docker with docker compose href 1e running supertokens and mysql with docker with docker compose a permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><a name=\"running-supertokens-and-mysql-with-docker-with-docker-compose\" href=\"\"> 1e) Running SuperTokens and MySQL with docker, with docker-compose </a></h2>\n<ul>\n<li>\n<p>Use the following docker compose file. You can call it <code class=\"language-text\">docker-compose.yaml</code></p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">version</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'3'</span>\n\n<span class=\"token key atrule\">services</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">db</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">image</span><span class=\"token punctuation\">:</span> mysql<span class=\"token punctuation\">:</span>latest\n    <span class=\"token key atrule\">environment</span><span class=\"token punctuation\">:</span>\n      <span class=\"token key atrule\">MYSQL_ROOT_PASSWORD</span><span class=\"token punctuation\">:</span> root\n      <span class=\"token key atrule\">MYSQL_USER</span><span class=\"token punctuation\">:</span> supertokens_user\n      <span class=\"token key atrule\">MYSQL_PASSWORD</span><span class=\"token punctuation\">:</span> somePassword\n      <span class=\"token key atrule\">MYSQL_DATABASE</span><span class=\"token punctuation\">:</span> supertokens\n    <span class=\"token key atrule\">ports</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> 3306<span class=\"token punctuation\">:</span><span class=\"token number\">3306</span>\n    <span class=\"token key atrule\">networks</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> app_network\n    <span class=\"token key atrule\">restart</span><span class=\"token punctuation\">:</span> unless<span class=\"token punctuation\">-</span>stopped\n    <span class=\"token key atrule\">healthcheck</span><span class=\"token punctuation\">:</span>\n      <span class=\"token key atrule\">test</span><span class=\"token punctuation\">:</span> <span class=\"token punctuation\">[</span> <span class=\"token string\">\"CMD\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"mysqladmin\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"ping\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"-h\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"localhost\"</span> <span class=\"token punctuation\">]</span>\n      <span class=\"token key atrule\">timeout</span><span class=\"token punctuation\">:</span> 20s\n      <span class=\"token key atrule\">retries</span><span class=\"token punctuation\">:</span> <span class=\"token number\">10</span>\n\n  <span class=\"token key atrule\">supertokens</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">image</span><span class=\"token punctuation\">:</span> registry.supertokens.io/supertokens/supertokens<span class=\"token punctuation\">-</span>mysql\n    <span class=\"token key atrule\">depends_on</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> db\n    <span class=\"token key atrule\">ports</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> 3567<span class=\"token punctuation\">:</span><span class=\"token number\">3567</span>\n    <span class=\"token key atrule\">environment</span><span class=\"token punctuation\">:</span>\n      <span class=\"token key atrule\">MYSQL_CONNECTION_URI</span><span class=\"token punctuation\">:</span> mysql<span class=\"token punctuation\">:</span>//supertokens_user<span class=\"token punctuation\">:</span>somePassword@db<span class=\"token punctuation\">:</span>3306/supertokens\n    <span class=\"token key atrule\">networks</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> app_network\n    <span class=\"token key atrule\">restart</span><span class=\"token punctuation\">:</span> unless<span class=\"token punctuation\">-</span>stopped\n    <span class=\"token key atrule\">healthcheck</span><span class=\"token punctuation\">:</span>\n      <span class=\"token key atrule\">test</span><span class=\"token punctuation\">:</span> <span class=\"token punctuation\">></span><span class=\"token scalar string\">\n        bash -c 'exec 3&lt;>/dev/tcp/127.0.0.1/3567 &amp;&amp; echo -e \"GET /hello HTTP/1.1\\r\\nhost: 127.0.0.1:3567\\r\\nConnection: close\\r\\n\\r\\n\" >&amp;3 &amp;&amp; cat &lt;&amp;3 | grep \"Hello\"'</span>\n      <span class=\"token key atrule\">interval</span><span class=\"token punctuation\">:</span> 10s\n      <span class=\"token key atrule\">timeout</span><span class=\"token punctuation\">:</span> 5s\n      <span class=\"token key atrule\">retries</span><span class=\"token punctuation\">:</span> <span class=\"token number\">5</span>\n\n<span class=\"token key atrule\">networks</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">app_network</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">driver</span><span class=\"token punctuation\">:</span> bridge</code></pre></div>\n</li>\n<li>\n<p>You can run the following command to start the service:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">docker-compose up</code></pre></div>\n</li>\n<li>\n<p>Verify that it is setup correctly by querying the core service:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"80093676756641480000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`curl http://localhost:3567/hello`, `80093676756641480000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">curl</span> http://localhost:3567/hello</code></pre></div>\n<p>If you get back a <code class=\"language-text\">Hello</code> reply, the core setup is done!</p>\n</li>\n</ul>\n<h2 id=\"a-namerunning-supertokens-and-postgresql-without-docker-href-2a-running-supertokens-and-postgresql-without-dockera\" style=\"position:relative;\"><a href=\"#a-namerunning-supertokens-and-postgresql-without-docker-href-2a-running-supertokens-and-postgresql-without-dockera\" aria-label=\"a namerunning supertokens and postgresql without docker href 2a running supertokens and postgresql without dockera permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><a name=\"running-supertokens-and-postgresql-without-docker\" href=\"\"> 2a) Running SuperTokens and PostgreSQL without docker</a></h2>\n<ul>\n<li>\n<p>Install SuperTokens on your local machine by following the <a href=\"https://supertokens.com/docs/thirdpartyemailpassword/quick-setup/core/without-docker\" target=\"_blank\" rel=\"nofollow\">self-hosted, without docker, instructions in the SuperTokens’ documentation</a>.</p>\n</li>\n<li>\n<p>Connect to the PostgreSQL server on your local machine and create a database for SuperTokens to write to:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"37683543878583615000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`CREATE DATABASE supertokens;`, `37683543878583615000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">CREATE</span> <span class=\"token keyword\">DATABASE</span> supertokens<span class=\"token punctuation\">;</span></code></pre></div>\n<p>If you already have a database for your application and want SuperTokens to create tables in that, you can skip this step.</p>\n</li>\n<li>\n<p>Create a PostgreSQL user that has full access to the database created in the previous step. This user will be used by SuperTokens to create and write to the database tables:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"7646021194667751000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`CREATE USER supertokens_user WITH ENCRYPTED PASSWORD 'somePassword';`, `7646021194667751000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">CREATE</span> <span class=\"token keyword\">USER</span> supertokens_user <span class=\"token keyword\">WITH</span> ENCRYPTED PASSWORD <span class=\"token string\">'somePassword'</span><span class=\"token punctuation\">;</span></code></pre></div>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"40339363584345140000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`GRANT ALL PRIVILEGES ON DATABASE supertokens TO supertokens_user;`, `40339363584345140000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">GRANT</span> <span class=\"token keyword\">ALL</span> <span class=\"token keyword\">PRIVILEGES</span> <span class=\"token keyword\">ON</span> <span class=\"token keyword\">DATABASE</span> supertokens <span class=\"token keyword\">TO</span> supertokens_user<span class=\"token punctuation\">;</span></code></pre></div>\n</li>\n<li>\n<p>Edit the SuperTokens <code class=\"language-text\">config.yaml</code> file (located in <code class=\"language-text\">/usr/lib/supertokens/config.yaml</code>) to add the following config:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"88430888517905290000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`postgresql_connection_uri: &quot;postgresql://supertokens_user:somePassword@localhost:5432/supertokens&quot;`, `88430888517905290000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">postgresql_connection_uri</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"postgresql://supertokens_user:somePassword@localhost:5432/supertokens\"</span></code></pre></div>\n<blockquote>\n<p>Make sure that you put in the right values for the user, password, database name and location of your postgreSQL instance in the above connection uri string.</p>\n</blockquote>\n</li>\n<li>\n<p>Run SuperTokens by running supertokens start on your terminal:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"17806525933556095000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`supertokens start\n\nLoading storage layer.\nLoading PostgreSQL config.\n...\nStarted SuperTokens on localhost:3567 with PID: ...`, `17806525933556095000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">supertokens start\n\nLoading storage layer.\nLoading PostgreSQL config.\n<span class=\"token punctuation\">..</span>.\nStarted SuperTokens on localhost:3567 with PID: <span class=\"token punctuation\">..</span>.</code></pre></div>\n</li>\n<li>\n<p>Verify that it is setup correctly by querying the core service:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"8812699907983456000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`curl http://localhost:3567/hello`, `8812699907983456000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">curl</span> http://localhost:3567/hello</code></pre></div>\n<p>If you get back a <code class=\"language-text\">Hello</code> reply, the core setup is done!</p>\n</li>\n</ul>\n<h2 id=\"a-namerunning-supertokens-with-docker-and-postgresql-without-docker-href-2b-running-supertokens-with-docker-and-postgresql-without-dockera\" style=\"position:relative;\"><a href=\"#a-namerunning-supertokens-with-docker-and-postgresql-without-docker-href-2b-running-supertokens-with-docker-and-postgresql-without-dockera\" aria-label=\"a namerunning supertokens with docker and postgresql without docker href 2b running supertokens with docker and postgresql without dockera permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><a name=\"running-supertokens-with-docker-and-postgresql-without-docker\" href=\"\"> 2b) Running SuperTokens with Docker and PostgreSQL without docker</a></h2>\n<p>For this setup to work, we must connect SuperTokens and PostgreSQL via the host machine’s network. For this, we will have to allow PostgreSQL to allow incomming client connections over the network.</p>\n<ul>\n<li>\n<p>Start by pulling the SuperTokens docker image that is compatible with PostgreSQL:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"37325553809821790000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker pull registry.supertokens.io/supertokens/supertokens-postgresql`, `37325553809821790000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> pull registry.supertokens.io/supertokens/supertokens-postgresql</code></pre></div>\n</li>\n<li>\n<p>Allow incoming client connections to your PostgreSQL database over your network by adding the following lines to the <code class=\"language-text\">postgresql.conf</code>and  <code class=\"language-text\">pg_hba.conf</code> file.</p>\n<p><code class=\"language-text\">postgresql.conf</code></p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">listen_addresses = '0.0.0.0'</code></pre></div>\n<p><code class=\"language-text\">pg_hba.conf</code></p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">host all all 0.0.0.0/0 md5</code></pre></div>\n</li>\n<li>\n<p>Connect to the PostgreSQL server on your local machine and create a database for SuperTokens to write to:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"8576945819010939000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`CREATE DATABASE supertokens;`, `8576945819010939000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">CREATE</span> <span class=\"token keyword\">DATABASE</span> supertokens<span class=\"token punctuation\">;</span></code></pre></div>\n<p>If you already have a database for your application and want SuperTokens to create tables in that, you can skip this step.</p>\n</li>\n<li>\n<p>Create a PostgreSQL user that has full access to the database created in the previous step. This user will be used by SuperTokens to create and write to the database tables:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"49473681527597875000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`CREATE USER supertokens_user with encrypted password 'somePassword';`, `49473681527597875000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">CREATE</span> <span class=\"token keyword\">USER</span> supertokens_user <span class=\"token keyword\">with</span> encrypted password <span class=\"token string\">'somePassword'</span><span class=\"token punctuation\">;</span></code></pre></div>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"2488415550958023000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`GRANT ALL PRIVILEGES ON DATABASE supertokens TO supertokens_user;`, `2488415550958023000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">GRANT</span> <span class=\"token keyword\">ALL</span> <span class=\"token keyword\">PRIVILEGES</span> <span class=\"token keyword\">ON</span> <span class=\"token keyword\">DATABASE</span> supertokens <span class=\"token keyword\">TO</span> supertokens_user<span class=\"token punctuation\">;</span></code></pre></div>\n</li>\n<li>\n<p>Run the SuperTokens docker image with the env var specifying the PostgreSQL connection URI:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"39168502238425825000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker run \\\n  -p 3567:3567 \\\n  --network=host \\\n  -e POSTGRESQL_CONNECTION_URI=&quot;postgresql://supertokens_user:somePassword@192.168.1.1:5432/supertokens&quot; \\\n  -d registry.supertokens.io/supertokens/supertokens-postgresql\n`, `39168502238425825000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> run <span class=\"token punctuation\">\\</span>\n  -p <span class=\"token number\">3567</span>:3567 <span class=\"token punctuation\">\\</span>\n  --network<span class=\"token operator\">=</span>host <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">POSTGRESQL_CONNECTION_URI</span><span class=\"token operator\">=</span><span class=\"token string\">\"postgresql://supertokens_user:somePassword@192.168.1.1:5432/supertokens\"</span> <span class=\"token punctuation\">\\</span>\n  -d registry.supertokens.io/supertokens/supertokens-postgresql\n</code></pre></div>\n<blockquote>\n<p>Be sure to replace <code class=\"language-text\">192.168.1.1</code> with the correct IP of your system.</p>\n</blockquote>\n<p>This will start the docker image in the background. You can find it by running:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">docker ps</code></pre></div>\n<p>If you want to run it in the foreground, you can remove the <code class=\"language-text\">-d</code> option from the <code class=\"language-text\">docker run</code> command.</p>\n</li>\n<li>\n<p>Verify that it is setup correctly by querying the core service:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"28796913271775980000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`curl http://localhost:3567/hello`, `28796913271775980000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">curl</span> http://localhost:3567/hello</code></pre></div>\n<p>If you get back a <code class=\"language-text\">Hello</code> reply, the core setup is done!</p>\n</li>\n</ul>\n<h2 id=\"a-namerunning-supertokens-without-docker-and-postgresql-with-docker-href-2c-running-supertokens-without-docker-and-postgresql-with-dockera\" style=\"position:relative;\"><a href=\"#a-namerunning-supertokens-without-docker-and-postgresql-with-docker-href-2c-running-supertokens-without-docker-and-postgresql-with-dockera\" aria-label=\"a namerunning supertokens without docker and postgresql with docker href 2c running supertokens without docker and postgresql with dockera permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><a name=\"running-supertokens-without-docker-and-postgresql-with-docker\" href=\"\"> 2c) Running SuperTokens without Docker and PostgreSQL with docker</a></h2>\n<ul>\n<li>\n<p>Install SuperTokens on your local machine by following the <a href=\"https://supertokens.com/docs/thirdpartyemailpassword/quick-setup/core/without-docker\" target=\"_blank\" rel=\"nofollow\">self-hosted, without docker, instructions in the SuperTokens’ documentation</a>.</p>\n</li>\n<li>\n<p>Start the PostgreSQL docker container:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"36971202868063480000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker run \\\n  -e POSTGRES_USER=root \\\n  -e POSTGRES_PASSWORD=root \\\n  --network=host \\\n  -p 5432:5432 \\\n  -d postgres \\\n  -c listen_addresses=0.0.0.0`, `36971202868063480000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> run <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">POSTGRES_USER</span><span class=\"token operator\">=</span>root <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">POSTGRES_PASSWORD</span><span class=\"token operator\">=</span>root <span class=\"token punctuation\">\\</span>\n  --network<span class=\"token operator\">=</span>host <span class=\"token punctuation\">\\</span>\n  -p <span class=\"token number\">5432</span>:5432 <span class=\"token punctuation\">\\</span>\n  -d postgres <span class=\"token punctuation\">\\</span>\n  -c <span class=\"token assign-left variable\">listen_addresses</span><span class=\"token operator\">=</span><span class=\"token number\">0.0</span>.0.0</code></pre></div>\n<p>The above will start the PostgreSQL db. You will need to connect to the database and create a user with the privileges.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"75850119268581560000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`CREATE DATABASE supertokens;`, `75850119268581560000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">CREATE</span> <span class=\"token keyword\">DATABASE</span> supertokens<span class=\"token punctuation\">;</span></code></pre></div>\n<p>If you already have a database for your application and want SuperTokens to create tables in that, you can skip this step.</p>\n</li>\n<li>\n<p>Create a PostgreSQL user that has full access to the database created in the previous step. This user will be used by SuperTokens to create and write to the database tables:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"57175958847580420000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`CREATE USER supertokens_user with encrypted password 'somePassword';`, `57175958847580420000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">CREATE</span> <span class=\"token keyword\">USER</span> supertokens_user <span class=\"token keyword\">with</span> encrypted password <span class=\"token string\">'somePassword'</span><span class=\"token punctuation\">;</span></code></pre></div>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"45555652907300770000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`GRANT ALL PRIVILEGES ON DATABASE supertokens TO supertokens_user;`, `45555652907300770000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">GRANT</span> <span class=\"token keyword\">ALL</span> <span class=\"token keyword\">PRIVILEGES</span> <span class=\"token keyword\">ON</span> <span class=\"token keyword\">DATABASE</span> supertokens <span class=\"token keyword\">TO</span> supertokens_user<span class=\"token punctuation\">;</span></code></pre></div>\n</li>\n<li>\n<p>Edit the SuperTokens <code class=\"language-text\">config.yaml</code> file (located in <code class=\"language-text\">/usr/lib/supertokens/config.yaml</code>) to add the following config:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"73065285282416116000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`postgresql_connection_uri: &quot;postgresql://supertokens_user:somePassword@localhost:5432/supertokens&quot;`, `73065285282416116000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">postgresql_connection_uri</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"postgresql://supertokens_user:somePassword@localhost:5432/supertokens\"</span></code></pre></div>\n<blockquote>\n<p>Make sure that you put in the right values for the user, password, database name and location of your PostgreSQL instance in the above connection uri string.</p>\n</blockquote>\n</li>\n<li>\n<p>Run SuperTokens by running <code class=\"language-text\">supertokens start</code> on your terminal:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"17821525132727923000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`supertokens start\n\nLoading storage layer.\nLoading PostgreSQL config.\n...\nStarted SuperTokens on localhost:3567 with PID: ...`, `17821525132727923000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">supertokens start\n\nLoading storage layer.\nLoading PostgreSQL config.\n<span class=\"token punctuation\">..</span>.\nStarted SuperTokens on localhost:3567 with PID: <span class=\"token punctuation\">..</span>.</code></pre></div>\n</li>\n<li>\n<p>Verify that it is setup correctly by querying the core service:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"70663298781117920000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`curl http://localhost:3567/hello`, `70663298781117920000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">curl</span> http://localhost:3567/hello</code></pre></div>\n<p>If you get back a <code class=\"language-text\">Hello</code> reply, the core setup is done!</p>\n</li>\n</ul>\n<h2 id=\"a-namerunning-supertokens-and-postgresql-with-docker-without-docker-compose-href-2d-running-supertokens-and-postgresql-with-docker-but-without-docker-compose-a\" style=\"position:relative;\"><a href=\"#a-namerunning-supertokens-and-postgresql-with-docker-without-docker-compose-href-2d-running-supertokens-and-postgresql-with-docker-but-without-docker-compose-a\" aria-label=\"a namerunning supertokens and postgresql with docker without docker compose href 2d running supertokens and postgresql with docker but without docker compose a permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><a name=\"running-supertokens-and-postgresql-with-docker-without-docker-compose\" href=\"\"> 2d) Running SuperTokens and PostgreSQL with docker, but without docker-compose </a></h2>\n<ul>\n<li>\n<p>Start by pulling the SuperTokens docker image that is compatible with PostgreSQL:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"22740180944157594000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker pull registry.supertokens.io/supertokens/supertokens-postgresql`, `22740180944157594000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> pull registry.supertokens.io/supertokens/supertokens-postgresql</code></pre></div>\n</li>\n<li>\n<p>Start the PostgreSQL docker container:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"4209608029566003000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker run \\\n  -e POSTGRES_USER=root \\\n  -e POSTGRES_PASSWORD=root \\\n  --network=host \\\n  -p 5432:5432 \\\n  -d postgres \\\n  -c listen_addresses=0.0.0.0`, `4209608029566003000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> run <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">POSTGRES_USER</span><span class=\"token operator\">=</span>root <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">POSTGRES_PASSWORD</span><span class=\"token operator\">=</span>root <span class=\"token punctuation\">\\</span>\n  --network<span class=\"token operator\">=</span>host <span class=\"token punctuation\">\\</span>\n  -p <span class=\"token number\">5432</span>:5432 <span class=\"token punctuation\">\\</span>\n  -d postgres <span class=\"token punctuation\">\\</span>\n  -c <span class=\"token assign-left variable\">listen_addresses</span><span class=\"token operator\">=</span><span class=\"token number\">0.0</span>.0.0</code></pre></div>\n<p>The above will start the PostgreSQL db. You will need to connect to the database and create a user with the privileges.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"85503040723156600000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`CREATE DATABASE supertokens;`, `85503040723156600000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">CREATE</span> <span class=\"token keyword\">DATABASE</span> supertokens<span class=\"token punctuation\">;</span></code></pre></div>\n<p>If you already have a database for your application and want SuperTokens to create tables in that, you can skip this step.</p>\n</li>\n<li>\n<p>Create a PostgreSQL user that has full access to the database created in the previous step. This user will be used by SuperTokens to create and write to the database tables:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"74768119272978680000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`CREATE USER supertokens_user with encrypted password 'somePassword';`, `74768119272978680000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">CREATE</span> <span class=\"token keyword\">USER</span> supertokens_user <span class=\"token keyword\">with</span> encrypted password <span class=\"token string\">'somePassword'</span><span class=\"token punctuation\">;</span></code></pre></div>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"87656015433686400000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`GRANT ALL PRIVILEGES ON DATABASE supertokens TO supertokens_user;`, `87656015433686400000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"sql\"><pre class=\"language-sql\"><code class=\"language-sql\"><span class=\"token keyword\">GRANT</span> <span class=\"token keyword\">ALL</span> <span class=\"token keyword\">PRIVILEGES</span> <span class=\"token keyword\">ON</span> <span class=\"token keyword\">DATABASE</span> supertokens <span class=\"token keyword\">TO</span> supertokens_user<span class=\"token punctuation\">;</span></code></pre></div>\n</li>\n<li>\n<p>Run the SuperTokens docker image with the env var specifying the PostgreSQL connection URI:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"71452616615937155000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker run \\\n  -p 3567:3567 \\\n  --network=host \\\n  -e POSTGRESQL_CONNECTION_URI=&quot;postgresql://supertokens_user:somePassword@192.168.1.1:5432/supertokens&quot; \\\n  -d registry.supertokens.io/supertokens/supertokens-postgresql\n`, `71452616615937155000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">docker</span> run <span class=\"token punctuation\">\\</span>\n  -p <span class=\"token number\">3567</span>:3567 <span class=\"token punctuation\">\\</span>\n  --network<span class=\"token operator\">=</span>host <span class=\"token punctuation\">\\</span>\n  -e <span class=\"token assign-left variable\">POSTGRESQL_CONNECTION_URI</span><span class=\"token operator\">=</span><span class=\"token string\">\"postgresql://supertokens_user:somePassword@192.168.1.1:5432/supertokens\"</span> <span class=\"token punctuation\">\\</span>\n  -d registry.supertokens.io/supertokens/supertokens-postgresql\n</code></pre></div>\n<blockquote>\n<p>Be sure to replace <code class=\"language-text\">192.168.1.1</code> with the correct IP of your system.</p>\n</blockquote>\n<p>This will start the docker image in the background. You can find it by running:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">docker ps</code></pre></div>\n<p>If you want to run it in the foreground, you can remove the <code class=\"language-text\">-d</code> option from the <code class=\"language-text\">docker run</code> command.</p>\n</li>\n<li>\n<p>Verify that it is setup correctly by querying the core service:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"74063526610460690000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`curl http://localhost:3567/hello`, `74063526610460690000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">curl</span> http://localhost:3567/hello</code></pre></div>\n<p>If you get back a <code class=\"language-text\">Hello</code> reply, the core setup is done!</p>\n<h2 id=\"a-namerunning-supertokens-and-postgresql-with-docker-with-docker-compose-href-2e-running-supertokens-and-postgresql-with-docker-with-docker-composea\" style=\"position:relative;\"><a href=\"#a-namerunning-supertokens-and-postgresql-with-docker-with-docker-compose-href-2e-running-supertokens-and-postgresql-with-docker-with-docker-composea\" aria-label=\"a namerunning supertokens and postgresql with docker with docker compose href 2e running supertokens and postgresql with docker with docker composea permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><a name=\"running-supertokens-and-postgresql-with-docker-with-docker-compose\" href=\"\"> 2e) Running SuperTokens and PostgreSQL with docker, with docker-compose</a></h2>\n</li>\n<li>\n<p>Use the following docker compose file. You can call it <code class=\"language-text\">docker-compose.yaml</code></p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">version</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'3'</span>\n\n<span class=\"token key atrule\">services</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">db</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">image</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'postgres:latest'</span>\n    <span class=\"token key atrule\">environment</span><span class=\"token punctuation\">:</span>\n      <span class=\"token key atrule\">POSTGRES_USER</span><span class=\"token punctuation\">:</span> supertokens_user \n      <span class=\"token key atrule\">POSTGRES_PASSWORD</span><span class=\"token punctuation\">:</span> somePassword \n      <span class=\"token key atrule\">POSTGRES_DB</span><span class=\"token punctuation\">:</span> supertokens\n    <span class=\"token key atrule\">ports</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> 5432<span class=\"token punctuation\">:</span><span class=\"token number\">5432</span>\n    <span class=\"token key atrule\">networks</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> app_network\n    <span class=\"token key atrule\">restart</span><span class=\"token punctuation\">:</span> unless<span class=\"token punctuation\">-</span>stopped\n    <span class=\"token key atrule\">healthcheck</span><span class=\"token punctuation\">:</span>\n      <span class=\"token key atrule\">test</span><span class=\"token punctuation\">:</span> <span class=\"token punctuation\">[</span><span class=\"token string\">'CMD'</span><span class=\"token punctuation\">,</span> <span class=\"token string\">'pg_isready'</span><span class=\"token punctuation\">,</span> <span class=\"token string\">'-U'</span><span class=\"token punctuation\">,</span> <span class=\"token string\">'supertokens_user'</span><span class=\"token punctuation\">,</span> <span class=\"token string\">'-d'</span><span class=\"token punctuation\">,</span> <span class=\"token string\">'supertokens'</span><span class=\"token punctuation\">]</span>\n      <span class=\"token key atrule\">interval</span><span class=\"token punctuation\">:</span> 5s\n      <span class=\"token key atrule\">timeout</span><span class=\"token punctuation\">:</span> 5s\n      <span class=\"token key atrule\">retries</span><span class=\"token punctuation\">:</span> <span class=\"token number\">5</span>\n\n  <span class=\"token key atrule\">supertokens</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">image</span><span class=\"token punctuation\">:</span> registry.supertokens.io/supertokens/supertokens<span class=\"token punctuation\">-</span>postgresql\n    <span class=\"token key atrule\">depends_on</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> db\n    <span class=\"token key atrule\">ports</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> 3567<span class=\"token punctuation\">:</span><span class=\"token number\">3567</span>\n    <span class=\"token key atrule\">environment</span><span class=\"token punctuation\">:</span>\n      <span class=\"token key atrule\">POSTGRESQL_CONNECTION_URI</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"postgresql://supertokens_user:somePassword@db:5432/supertokens\"</span>\n    <span class=\"token key atrule\">networks</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> app_network\n    <span class=\"token key atrule\">restart</span><span class=\"token punctuation\">:</span> unless<span class=\"token punctuation\">-</span>stopped\n    <span class=\"token key atrule\">healthcheck</span><span class=\"token punctuation\">:</span>\n      <span class=\"token key atrule\">test</span><span class=\"token punctuation\">:</span> <span class=\"token punctuation\">></span><span class=\"token scalar string\">\n        bash -c 'exec 3&lt;>/dev/tcp/127.0.0.1/3567 &amp;&amp; echo -e \"GET /hello HTTP/1.1\\r\\nhost: 127.0.0.1:3567\\r\\nConnection: close\\r\\n\\r\\n\" >&amp;3 &amp;&amp; cat &lt;&amp;3 | grep \"Hello\"'</span>\n      <span class=\"token key atrule\">interval</span><span class=\"token punctuation\">:</span> 10s\n      <span class=\"token key atrule\">timeout</span><span class=\"token punctuation\">:</span> 5s\n      <span class=\"token key atrule\">retries</span><span class=\"token punctuation\">:</span> <span class=\"token number\">5</span>\n\n<span class=\"token key atrule\">networks</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">app_network</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">driver</span><span class=\"token punctuation\">:</span> bridge\n  </code></pre></div>\n</li>\n<li>\n<p>You can run the following command to start the service:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">docker-compose up</code></pre></div>\n</li>\n<li>\n<p>Verify that it is setup correctly by querying the core service:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"21856370405775684000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied!\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`curl http://localhost:3567/hello`, `21856370405775684000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                <svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">curl</span> http://localhost:3567/hello</code></pre></div>\n<p>If you get back a <code class=\"language-text\">Hello</code> reply, the core setup is done!</p>\n</li>\n</ul>","frontmatter":{"date":"April 24, 2022","title":"How to connect SuperTokens to a MySQL or to a PostgreSQL database","cover":"supertokens-db.png","author":"Rishabh Poddar","description":"Learn how to connect a self-hosted SuperTokens core to a database with or without Docker"},"fields":{"slug":"/connect-supertokens-to-database/"}},"site":{"siteMetadata":{"title":"SuperTokens Blog"}}},"pageContext":{"id":"46dfd198-38c3-5d8b-a502-a30fc021da50","fields__slug":"/connect-supertokens-to-database/","__params":{"fields__slug":"connect-supertokens-to-database"}}},
    "staticQueryHashes": []}