# Own db connection

**URL:** <https://community.auth0.com/t/own-db-connection/36881>\
**Category:** Get Help\
**Created:** [January 27, 2020, 10:41am UTC](https://community.auth0.com/t/own-db-connection/36881 "2020-01-27T10:41:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![haroon.momin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/haroon.momin/32/13039_2.png) [@haroon.momin](https://community.auth0.com/u/haroon.momin)\
**Post date:** [January 27, 2020, 10:41am UTC](https://community.auth0.com/t/own-db-connection/36881/1 "2020-01-27T10:41:33Z")

</div>

Hi,  
I am using auth0’s custom DB connection. with its “own custom DB feature”.  
I am trying to connect my local DB with it. with the help of ngrok.  
On click of TRY link, the below error is showing.  
“[SandboxUnhandledError] MySQL is not a function”.  
And in the Real-time webtask. the below message is showed.  
{  
“code”: 500,  
“error”: “Script generated an unhandled synchronous exception.”,  
“details”: “TypeError: mysql is not a function”,  
“name”: “TypeError”,  
“message”: “mysql is not a function”,  
“stack”: “TypeError: mysql is not a function\n at getByEmail (/data/io/c6efb891-6882-4a64-b906-d9471f16da8f/webtask.js:9:22)\n at /data/io/c6efb891-6882-4a64-b906-d9471f16da8f/webtask.js:31:2\n at Async.waterfall (/data/sandbox/lib/sandbox.js:617:33)\n at nextTask (/data/sandbox/node\_modules/async/dist/async.js:5324:14)\n at next (/data/sandbox/node\_modules/async/dist/async.js:5331:9)\n at /data/sandbox/node\_modules/async/dist/async.js:969:16\n at Async.waterfall (/data/sandbox/lib/sandbox.js:506:24)\n at nextTask (/data/sandbox/node\_modules/async/dist/async.js:5324:14)\n at next (/data/sandbox/node\_modules/async/dist/async.js:5331:9)\n at /data/sandbox/node\_modules/async/dist/async.js:969:16”  
}  
plz guide me…

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [January 27, 2020, 3:59pm UTC](https://community.auth0.com/t/own-db-connection/36881/2 "2020-01-27T15:59:30Z")

</div>

You should share the custom database script code (redacting any sensitive information like URL, passwords, etc); ideally you should not even have those in the code and use configuration variables, but since you’re starting the implementation you may still have those in code, hence the warning.

The error seems related to the Javascript code itself, in particular with the usage of a module to connect to MySQL. We have templates for MySQL available at ([Login Script Templates](https://auth0.com/docs/connections/database/custom-db/templates/login#mysql)); are you using those as reference already?

---

<div class="post-metadata">

**Author:** ![haroon.momin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/haroon.momin/32/13039_2.png) [@haroon.momin](https://community.auth0.com/u/haroon.momin)\
**Post date:** [January 28, 2020, 4:44am UTC](https://community.auth0.com/t/own-db-connection/36881/3 "2020-01-28T04:44:14Z")

</div>

yes, i am using those ref.  
I am using the mysql readymade templates with own custom DB.  
const connection = mysql({  
host: ‘[d2c6ec27.ngrok.io](http://d2c6ec27.ngrok.io)’, //host which is ngrok link to my local pc  
user: ‘root’, //username  
password: ‘’, //password is blank  
port :‘3306’, //port  
database: ‘hotstarapp’ //db name  
});  
when i am clicking on TRY button the error is showing while creating a user.  
and also sometimes it shows following error.  
“[Error] ETIMEDOUT - connect ETIMEDOUT”  
i have also checked it with Realtime weblog.  
which is showing below  
{  
“code”: 500,  
“error”: “Script generated an unhandled synchronous exception.”,  
“details”: “TypeError: mysql is not a function”,  
“name”: “TypeError”,  
“message”: “mysql is not a function”,  
“stack”: “TypeError: mysql is not a function\n at getByEmail (/data/io/c6efb891-6882-4a64-b906-d9471f16da8f/webtask.js:9:22)\n at /data/io/c6efb891-6882-4a64-b906-d9471f16da8f/webtask.js:31:2\n at Async.waterfall (/data/sandbox/lib/sandbox.js:617:33)\n at nextTask (/data/sandbox/node\_modules/async/dist/async.js:5324:14)\n at next (/data/sandbox/node\_modules/async/dist/async.js:5331:9)\n at /data/sandbox/node\_modules/async/dist/async.js:969:16\n at Async.waterfall (/data/sandbox/lib/sandbox.js:506:24)\n at nextTask (/data/sandbox/node\_modules/async/dist/async.js:5324:14)\n at next (/data/sandbox/node\_modules/async/dist/async.js:5331:9)\n at /data/sandbox/node\_modules/async/dist/async.js:969:16”  
}  
i am a biginner so very confusing me. plz do help ASAP.

---

<div class="post-metadata">

**Author:** ![haroon.momin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/haroon.momin/32/13039_2.png) [@haroon.momin](https://community.auth0.com/u/haroon.momin)\
**Post date:** [January 29, 2020, 12:43pm UTC](https://community.auth0.com/t/own-db-connection/36881/4 "2020-01-29T12:43:19Z")

</div>

Hi @jmangelo,  
Now i have encounter with this error.  
“401 - Unauthorized”  
Plz do reply.

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [February 4, 2020, 1:25am UTC](https://community.auth0.com/t/own-db-connection/36881/5 "2020-02-04T01:25:11Z")

</div>

If you haven’t done so already you should check ([Custom database error - "mysql is not a function"?](http://community.auth0.com/t/custom-database-error-mysql-is-not-a-function/21052)) which has some relevant information from someone that experienced similar issues.

---

<div class="post-metadata">

**Author:** ![haroon.momin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/haroon.momin/32/13039_2.png) [@haroon.momin](https://community.auth0.com/u/haroon.momin)\
**Post date:** [February 29, 2020, 10:50am UTC](https://community.auth0.com/t/own-db-connection/36881/6 "2020-02-29T10:50:39Z")

</div>

In Own custom DB, with laravel 6.0 how to call those login, logout scripts/functions with controller and in routes.

like this:  
In controller file  
public function login()  
{  
return \App::make(‘auth0’)-\>login(null, null, [‘scope’ =\> ‘openid name email email\_verified’], ‘code’);  
}  
And Route would be like this  
Route::get(‘/login’, ‘Auth\Auth0IndexController@login’ )-\>name(‘login’)-\>middleware(‘web’);  
Or i have to use any other way? plz guide me
