# History Database Connection

**URL:** <https://forum.inductiveautomation.com/t/history-database-connection/31278>\
**Category:** Ignition\
**Created:** [January 14, 2020, 2:51pm UTC](https://forum.inductiveautomation.com/t/history-database-connection/31278 "2020-01-14T14:51:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.stevic](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@thomas.stevic](https://forum.inductiveautomation.com/u/thomas.stevic)\
**Post date:** [January 14, 2020, 2:51pm UTC](https://forum.inductiveautomation.com/t/history-database-connection/31278/1 "2020-01-14T14:51:23Z")

</div>

I am trying to get a database connection working so I might set up tag history.

I am using SQL Server. ( I am not a database person)

The connection name is MSSQLServer.  
The JDBC driver is Microsoft SQLServer.  
The database is local, so the connect URL is jdbc:sqlserver://localhost\SQLExpress:1433.  
The user name is Ignition.  
Extra Connection Properties are databaseName=msign.  
Enabled is checked.  
Translator = MSSQL.  
Include Schema in Table Name is checked.  
Connection Pooling, Connection Testing, and Connection Initialization are default.

Database Connections show the connection as valid.

The SQL Server Management has:  
Login = Ignition + password.  
Server Roles has ‘public’ checked.  
User mapping has the msign database checked. The roles are db datareader, db datawriter, and public checked.  
Securables has (My computer name)\SQLEXPRESS as the server.  
Explicit permissions are ‘connect SQL’ -Grantor sa, ‘Create any database’ – Grantor sa.  
Effective Permissions are ‘CONNECT SQL, CREATE ANY DATABASE, VIEW ANY DATABASE.  
Status Grant to database engine, Login Enabled.  
Msign database has User and Login name = Ignition. Default schema dbo.  
Owned Schemas all unchecked.  
Role Member db\_datareader and db\_datawriter checked.  
Securables is empty.  
Extended Properties Database msign, Collation SQL\_Latin1\_General\_CP1\_CI\_AS

History Datasource history Provider status is Running.

The tag is an OPC Integer that has random numbers written by the PLC. I can watch the values change from the Tag Browser in Ignition Designer.

History Enabled = true  
Storage Provider = MSSQLServer  
Deadband Style = Auto  
Deadband Mode = Absolute  
Historical Deadband = 15.0  
Sample Mode = Periodic  
Max Time Between Samples = 10 Seconds  
Sample Rate = 5 Seconds

I can run the SQL Query ‘Select Record From dbo.Table\_1’ from the Database Query Browser and it returns some stuff from the ‘Record’ column in the msign database

I have two tags, ‘Query Tag’ and ‘Int\_1’. Both point to the same register in the PLC. ‘Query Tag’ does not have history enabled, ‘Int\_1’ does have history enabled.

I can drag and drop ‘Query Tag’ on an Easy Chart and everyone is happy.  
If I drag and drop the ‘Int\_1’ on the same chart, I get:

* * *

Exception: Error running query:  
Tag Density Histogram Query  
Range: Tue Jan 14 08:00:00 EST 2020-\>Tue Jan 14 09:59:59 EST 2020  
Paths:  
prov:default:/tag:Query Tag  
prov:default:/tag:Int\_1  
@0ms  
On: New Main Window.Root Container.Easy Chart

caused by GatewayException: Error executing tag history query. Please verify that the connection is available, and that tag history is being stored to it.

caused by Exception: Error executing tag history query. Please verify that the connection is available, and that tag history is being stored to it.

Ignition v8.0.6 (b2019111216)  
Java: Azul Systems, Inc. 11.0.4

* * *

Read and Write and enabled. Any suggestions as to where to look?  
I can see no tables in the database that are created by Ignition. Does the table have a specific name?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 14, 2020, 3:25pm UTC](https://forum.inductiveautomation.com/t/history-database-connection/31278/2 "2020-01-14T15:25:27Z")

</div>

I’m not a SQL Server expert, but your symptoms suggest that the Ignition user in the DB doesn’t have the privileges needed to create the historian tables.

---

<div class="post-metadata">

**Author:** ![thomas.stevic](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@thomas.stevic](https://forum.inductiveautomation.com/u/thomas.stevic)\
**Post date:** [January 14, 2020, 3:32pm UTC](https://forum.inductiveautomation.com/t/history-database-connection/31278/3 "2020-01-14T15:32:51Z")

</div>

I agree. The connection seems to be working. Not being a SQL expert either, I am at a bit of a loss figuring out what permissions the tag needs.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 14, 2020, 3:36pm UTC](https://forum.inductiveautomation.com/t/history-database-connection/31278/4 "2020-01-14T15:36:18Z")

</div>

> [@thomas.stevic](#):
>
> what permissions the tag needs.

Not the tags. The Ignition user in the DB. When I create DB instances in other brands, I usually just make the Ignition user be the owner from the start, so it has all necessary permissions.

---

<div class="post-metadata">

**Author:** ![thomas.stevic](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@thomas.stevic](https://forum.inductiveautomation.com/u/thomas.stevic)\
**Post date:** [January 14, 2020, 3:39pm UTC](https://forum.inductiveautomation.com/t/history-database-connection/31278/5 "2020-01-14T15:39:00Z")

</div>

Solved for the moment. I gave Ignition the permission to ‘Alter any database’ and everyone seems happy again. Perhaps that is overkill, but that is an issue for another day.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [January 14, 2020, 6:59pm UTC](https://forum.inductiveautomation.com/t/history-database-connection/31278/6 "2020-01-14T18:59:10Z")

</div>

It doesn’t need alter ANY database.  
Just make the login you created the Owner of the database you want to use for historian.

---

<div class="post-metadata">

**Author:** ![thomas.stevic](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@thomas.stevic](https://forum.inductiveautomation.com/u/thomas.stevic)\
**Post date:** [January 14, 2020, 7:12pm UTC](https://forum.inductiveautomation.com/t/history-database-connection/31278/7 "2020-01-14T19:12:30Z")

</div>

I shall try that indeed.

---

<div class="post-metadata">

**Author:** ![netliuhao](https://avatars.discourse-cdn.com/v4/letter/n/8baadc/32.png) [@netliuhao](https://forum.inductiveautomation.com/u/netliuhao)\
**Post date:** [April 25, 2021, 7:27am UTC](https://forum.inductiveautomation.com/t/history-database-connection/31278/8 "2021-04-25T07:27:53Z")

</div>

[https://docs.inductiveautomation.com/display/DOC/Installing+MySQL](https://docs.inductiveautomation.com/display/DOC/Installing+MySQL)

[https://docs.inductiveautomation.com/display/DOC/Connecting+to+MySQL](https://docs.inductiveautomation.com/display/DOC/Connecting+to+MySQL)

above link will tech you :how to install and connect MYsql database . i finish it before some days .

[https://docs.inductiveautomation.com/display/DOC/Database+Connections](https://docs.inductiveautomation.com/display/DOC/Database+Connections)  
the page will tech you : how to install another type database in you computer . see bottom of this page.
