# Can Dreamfactory use any other kind of database other than MySQL to store its to store user, role, and service information?

**URL:** <https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425>\
**Category:** Connecting to SQL\
**Created:** [August 27, 2015, 7:32am UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425 "2015-08-27T07:32:37Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chakr](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@Chakr](https://community.dreamfactory.com/u/Chakr)\
**Post date:** [August 27, 2015, 7:32am UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/1 "2015-08-27T07:32:38Z")

</div>

I’m using dreamfactory on bluemix. I’m currently using a Clear db MySQL database to setup dreamfactory. Is it possible to set it up on a IBM DB2 database? I don’t mean as a service. I want to use DB2 as the database for dreamfactory, as a requirement for it to run at all.

---

<div class="post-metadata">

**Author:** ![Im\_PJ](https://avatars.discourse-cdn.com/v4/letter/i/59ef9b/32.png) [@Im\_PJ](https://community.dreamfactory.com/u/Im_PJ)\
**Post date:** [August 28, 2015, 3:06am UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/2 "2015-08-28T03:06:32Z")

</div>

> [@User registration, authentication and authorization in a different database](https://community.dreamfactory.com/t/user-registration-authentication-and-authorization-in-a-different-database/716/8):
>
> 2.0 will let you select any SQL database to store user and role data (currently user and role data is stored in MySQL only). 2.0 will also make it easy to authenticate users with OAuth and Active Directory. Permanent login (i.e. no session timeout) will also be supported in 2.0. So you won’t have to use LDAP for any of the features above. It’s all built into the 2.0 platform. Why do you need to port the user data to DynamoDB? We’re a little behind, but 2.0 code should be public on GitHub in a …

Not possible as of now. But they promise to support this feature with DF v2.0.  
And I’m eagerly waiting for that.

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [August 28, 2015, 5:11am UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/3 "2015-08-28T05:11:41Z")

</div>

2.0 will let you pick your database. 2.0 will be in beta on Bitnami first week of Sep.

---

<div class="post-metadata">

**Author:** ![Im\_PJ](https://avatars.discourse-cdn.com/v4/letter/i/59ef9b/32.png) [@Im\_PJ](https://community.dreamfactory.com/u/Im_PJ)\
**Post date:** [October 1, 2015, 5:07am UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/4 "2015-10-01T05:07:01Z")

</div>

@benbusse I’m trying to do this in DF2. I want to use different db for user management and be able to use this api call- `api/v2/user/session/` with my own db?  
As per your blog, \> Pick default SQL database of choice (no longer limited to MySQL).  
Lack of documentation makes it difficult to use such features of DF2.

---

<div class="post-metadata">

**Author:** ![aislam](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/aislam/32/421_2.png) [@aislam](https://community.dreamfactory.com/u/aislam)\
**Post date:** [October 1, 2015, 1:02pm UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/5 "2015-10-01T13:02:12Z")

</div>

DreamFactory 2.0 is built using Laravel 5.1 PHP framework. So, it supports all databases that Laravel supports out of the box. You can easily configure this in the config/database.php config file. Details are documented in the file. However, Laravel doesn’t support IBM DB2 out of the box. But I found this third party package [https://github.com/cooperl22/laravel-db2](https://github.com/cooperl22/laravel-db2) that you can check out. I have not tried this package but it’s popular enough to show up in several forums while I was doing my search.

---

<div class="post-metadata">

**Author:** ![Im\_PJ](https://avatars.discourse-cdn.com/v4/letter/i/59ef9b/32.png) [@Im\_PJ](https://community.dreamfactory.com/u/Im_PJ)\
**Post date:** [October 1, 2015, 7:03pm UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/6 "2015-10-01T19:03:14Z")

</div>

Thanks but I was looking for a way to setup my own user db through admin console. Its a feature of DF2 so I dont want to change config in php files. My question is not related to IBM DB2 but in general how to have your own user db and be able to use such api calls `api/v2/user/session/` with it.

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [October 1, 2015, 7:40pm UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/7 "2015-10-01T19:40:20Z")

</div>

Once you do set up the `database.php` config file to point to your DB of choice, the whole DreamFactory user DB will be created in that target DB. If you’re not willing to change the config of which DB that DF2 uses as its system DB, then you will not be able to replace the default DB with the DB of your choice for system calls like `/api/v2/user/session`.

---

<div class="post-metadata">

**Author:** ![Im\_PJ](https://avatars.discourse-cdn.com/v4/letter/i/59ef9b/32.png) [@Im\_PJ](https://community.dreamfactory.com/u/Im_PJ)\
**Post date:** [October 3, 2015, 3:40am UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/8 "2015-10-03T03:40:50Z")

</div>

@aislam @jeffreystables I did what you suggested but it breaks the whole system. I hope you meant to change the below code in database.php

```
'dreamfactory' => [
            'driver' => 'dblib',
            'host' => env('DB_HOST', 'hostname'),
                        'port' => env('DB_PORT', 'portno'),
            'database' => env('DB_DATABASE', 'dbname'),
            'username' => env('DB_USERNAME', 'uname'),
            'password' => env('DB_PASSWORD', 'pwd'),
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => false,
        ],  

```

I created an empty sql serv DB and changed parameters above to connect to it. Do I need to create the table structures that DF uses or it will be auto generated. can you pls write the steps in detail. This shouldn’t be so difficult to do if its a feature of DF2.

---

<div class="post-metadata">

**Author:** ![aislam](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/aislam/32/421_2.png) [@aislam](https://community.dreamfactory.com/u/aislam)\
**Post date:** [October 13, 2015, 6:20pm UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/9 "2015-10-13T18:20:01Z")

</div>

Instead of ‘dblib’ use ‘sqlsrv’ for driver. Laravel will automatically use ‘dblib’ driver if is installed. Once you make that change run “sudo php artisan cache:clear” in the DreamFactory installation root directly. This will clear all system caches. Please make sure that your database is created and empty then Access your DreamFactory instance on a browser. You should see a welcome page followed by a form to create the first admin user.

---

<div class="post-metadata">

**Author:** ![Im\_PJ](https://avatars.discourse-cdn.com/v4/letter/i/59ef9b/32.png) [@Im\_PJ](https://community.dreamfactory.com/u/Im_PJ)\
**Post date:** [October 14, 2015, 3:14am UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/10 "2015-10-14T03:14:15Z")

</div>

@aislam I still get this error and HTTP 500 in access log. ![](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/dreamfactory/original/1X/3f8ffc9f99a932d7db1bced16f5f49d1f93043bd.png)

This is what I changed in database.php

```
   'default' => 'df2',
    'df2' => [
                'driver' => 'sqlsrv',
                'host' => '10.20.0.1',
                'port' => '1433',
                'database' => 'bitnamidb',
                'username' => 'user',
                'password' => 'user@4562' ]

```

After that I ran command `sudo php artisan cache:clear` and got message **application cache cleared**. Then I access dreamfactory in browser but get the above error. I created empty database without any tables as u suggested. Where I’m going wrong? connection to db is working as I have tested it inside df sql services.

---

<div class="post-metadata">

**Author:** ![aislam](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/aislam/32/421_2.png) [@aislam](https://community.dreamfactory.com/u/aislam)\
**Post date:** [October 14, 2015, 8:24pm UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/11 "2015-10-14T20:24:42Z")

</div>

First, make sure your web server can read/write to storage/ and bootstrap/cache directories. If you are still getting 500 then check the log in storage/logs/ directory. Or you can also enable debugging in the .env file. Set APP\_DEBUG to true there. It should give you a stack trace after the ‘Whoops, looks like something went wrong.’ error.

---

<div class="post-metadata">

**Author:** ![Im\_PJ](https://avatars.discourse-cdn.com/v4/letter/i/59ef9b/32.png) [@Im\_PJ](https://community.dreamfactory.com/u/Im_PJ)\
**Post date:** [October 15, 2015, 5:23am UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/12 "2015-10-15T05:23:34Z")

</div>

@aislam my apache user has 0777 permissions on those folders. Still the same error. This is from the starting of logs. More such error at bottom.

```
Could not get cors config from DB - SQLSTATE[HY000]: General error: 208 General SQL Server error: Check messages from the SQL Server [208] (severity 16) [(null)] (SQL: select * from [cors_config] where enabled = 1)  

PDOException' with message 'SQLSTATE[HY000]: General error: 208 General SQL Server error in /dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Database/Connection.php:312 

```

I don’t see any tables created in the remote db. 😕

---

<div class="post-metadata">

**Author:** ![aislam](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/aislam/32/421_2.png) [@aislam](https://community.dreamfactory.com/u/aislam)\
**Post date:** [October 15, 2015, 2:36pm UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/13 "2015-10-15T14:36:48Z")

</div>

That error at the starting of the log is normal (unless you see that happening again anywhere else in the log file). On the first run DreamFactory encounters this error (hence you see it in the log) and then goes ahead creates the system tables. Did you try setting the APP\_DEBUG=true in the .env file and accessing the system on browser to see the error stack trace? If not then please try it to see the actual error message.

---

<div class="post-metadata">

**Author:** ![Im\_PJ](https://avatars.discourse-cdn.com/v4/letter/i/59ef9b/32.png) [@Im\_PJ](https://community.dreamfactory.com/u/Im_PJ)\
**Post date:** [October 15, 2015, 3:22pm UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/14 "2015-10-15T15:22:22Z")

</div>

@aislam I couldn’t find .env file so I created file “local.env” in dreamfactory/htdocs and have put APP\_DEBUG=true there.  
I’m not familiar with laravel setup so let me know if this is correct. This is one more SQL error from the logs.

```
(SQL: select count(*) as aggregate from [user] where [is_active] = 1 and [is_sys_admin] = 1)'
```

---

<div class="post-metadata">

**Author:** ![aislam](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/aislam/32/421_2.png) [@aislam](https://community.dreamfactory.com/u/aislam)\
**Post date:** [October 15, 2015, 5:51pm UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/15 "2015-10-15T17:51:46Z")

</div>

There should be a .env file in the dreamfactory/htdocs directory. Sometimes it’s hidden by OS. So, you may need to unhide your hidden files to see it. Putting a local.env won’t make any difference. My email address is [arif@dreamfactory.com](mailto:arif@dreamfactory.com). Please send me your log file so that I can look at it.

---

<div class="post-metadata">

**Author:** ![Im\_PJ](https://avatars.discourse-cdn.com/v4/letter/i/59ef9b/32.png) [@Im\_PJ](https://community.dreamfactory.com/u/Im_PJ)\
**Post date:** [October 15, 2015, 6:31pm UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/17 "2015-10-15T18:31:10Z")

</div>

Thanks. I’m getting the stack trace now. I have mailed you the log file. pls have a look.

---

<div class="post-metadata">

**Author:** ![Val](https://avatars.discourse-cdn.com/v4/letter/v/e56c9b/32.png) [@Val](https://community.dreamfactory.com/u/Val)\
**Post date:** [November 2, 2015, 11:07pm UTC](https://community.dreamfactory.com/t/can-dreamfactory-use-any-other-kind-of-database-other-than-mysql-to-store-its-to-store-user-role-and-service-information/1425/18 "2015-11-02T23:07:49Z")

</div>

I tried to follow the steps here for v. 2.0.1 to connect to SQL DB and I don’t see any errors nor changes to existing behavior.  
I updated:  
‘default’ =\> env(‘DB\_DRIVER’, ‘sqlsrv’),  
…

```
	'sqlsrv' => [
		'driver' => 'sqlsrv',
		'host' => env('DB_HOST', 'localhost\sqlexpress'),
		'database' => env('DB_DATABASE', 'DreamFactory'),
		'username' => env('DB_USERNAME', 'dreamuser'),
		'password' => env('DB_PASSWORD', 'dreamuser'),
		'port' => env('DB_PORT', '6806'),
		'prefix' => '',
	],
```
