> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a database

> Create a FlexiCapture database from the Administration and Monitoring Console, install client drivers, set up file storage, and grant engine permissions.

You create a FlexiCapture database from the Administration and Monitoring Console. Depending on your setup, you can create a new database or [connect to an existing database](/flexi-capture/admin-guide/database-connect).

<Note>
  In ABBYY FlexiCapture Release 4 Update 2, PostgreSQL is enabled by default. In earlier versions, [enable PostgreSQL](/flexi-capture/postgres-sql-enable) before you can work with PostgreSQL databases.
</Note>

## Create a new database

<Steps>
  <Step title="Install the database client driver">
    On the computer where the Application Server is installed, install one of the following client drivers:

    * [Microsoft SQL Server Native Client](https://www.microsoft.com/en-us/download/details.aspx?id=50402) 2012 or later
    * [Oracle Data Access Components (ODAC)](https://www.oracle.com/database/technologies/odac-downloads.html) of the same bitness as the Application Server
    * [psqlODBC](https://odbc.postgresql.org/) version 11 or later

    If you attempt to create a database without Microsoft SQL Server Native Client, you see this error message: `Provider cannot be found. It may not be properly installed.`

    <Note>
      You don't need to install Microsoft SQL Server Native Client if you have Microsoft SQL Server 2016 SP2 or later, or Microsoft SQL Management Studio 2016 SP2 or later, installed.
    </Note>
  </Step>

  <Step title="Open the Administration and Monitoring Console">
    On the computer where the Application Server is installed, sign in with the Windows administrator account. Open the Administration and Monitoring Console and click **Service → Application Server** to open the page `https://<ApplicationServer>/FlexiCapture12/Monitoring/#Settings/DbConn`, where `<ApplicationServer>` is the name of the computer that hosts the Application Server.

    <Frame>
      <img src="https://mintcdn.com/abbyy/mpS3pcxC_lkohQUS/images/flexi-capture/No_DB_connection.png?fit=max&auto=format&n=mpS3pcxC_lkohQUS&q=85&s=7bd6b6d62709a61d2949a5b067b3426a" alt="Screenshot of the Application Server page in the FlexiCapture Administration and Monitoring Console before a database is connected, showing the Create New Database button." width="948" height="382" data-path="images/flexi-capture/No_DB_connection.png" />
    </Frame>

    <Note>
      If you are already connected to another database, close the existing sessions before creating a new database. If that is not possible or necessary, add the following key to the `web.config` file located at `<IIS Root Directory>\FlexiCapture12\Monitoring` (the default IIS root location is `C:\inetpub\wwwroot`):

      ```xml theme={null}
      <appSettings>
      <add key="IgnoreCurrentSessions" value="true"/>
      </appSettings>
      ```

      The new database is then created without a warning about existing sessions, and all sessions in the old database are preserved. By default, the key is set to `false` and you are prompted to close the sessions when creating a new database.
    </Note>
  </Step>

  <Step title="Specify the connection settings">
    Click the **Create New Database** button. On the database creation page that opens, specify:

    * The server instance name, in the format `<server name>\<instance name>`.
    * The name of the new database.
    * A user account with the necessary permissions for your database.

    Choose the TCP/IP protocol rather than Named Pipes to communicate with the database server. You set the protocol when you configure the Microsoft SQL Server client on the computer that hosts the Application Server.

    Select your database type for its screenshot and specific requirements:

    <Tabs>
      <Tab title="Microsoft SQL Server">
        <Frame>
          <img src="https://mintcdn.com/abbyy/IFr-A2MDVJd80FDs/images/flexi-capture/DB_new_connection_SQL.jpg?fit=max&auto=format&n=IFr-A2MDVJd80FDs&q=85&s=80dfb29d66da3edbdde50d12cfaa9e4f" alt="Screenshot of the Create new database page in the FlexiCapture Administration and Monitoring Console with the MS SQL option selected, showing the server instance name, database name, and authentication fields." width="1199" height="875" data-path="images/flexi-capture/DB_new_connection_SQL.jpg" />
        </Frame>

        Note the limitations that Microsoft SQL Server imposes on database names. For more information, see [this Microsoft website](https://msdn.microsoft.com/en-us/library/ms175874.aspx).
      </Tab>

      <Tab title="Oracle">
        <Frame>
          <img src="https://mintcdn.com/abbyy/IFr-A2MDVJd80FDs/images/flexi-capture/DB_new_connection_Oracle.jpg?fit=max&auto=format&n=IFr-A2MDVJd80FDs&q=85&s=f7a7f9369829867f00e2a88b854c8a7e" alt="Screenshot of the Create new database page in the FlexiCapture Administration and Monitoring Console with the Oracle option selected, showing the server instance name and server access authentication fields." width="1199" height="875" data-path="images/flexi-capture/DB_new_connection_Oracle.jpg" />
        </Frame>

        The connecting user must have the "DBA" WITH ADMIN OPTION role and the EXECUTE privilege on "SYS"."DBMS\_LOCK". Note the Oracle restrictions on user names. For more information, see the [Oracle website](https://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements008.htm#i27570).
      </Tab>

      <Tab title="Azure">
        <Frame>
          <img src="https://mintcdn.com/abbyy/IFr-A2MDVJd80FDs/images/flexi-capture/DB_new_connection_Azure.jpg?fit=max&auto=format&n=IFr-A2MDVJd80FDs&q=85&s=5a23fa8dd8afed853ed14e62d4e6a8ab" alt="Screenshot of the Create new database page in the FlexiCapture Administration and Monitoring Console with the Azure option selected, showing the server instance name, database name, and database server authentication fields." width="1198" height="874" data-path="images/flexi-capture/DB_new_connection_Azure.jpg" />
        </Frame>
      </Tab>

      <Tab title="PostgreSQL">
        <Frame>
          <img src="https://mintcdn.com/abbyy/IFr-A2MDVJd80FDs/images/flexi-capture/DB_new_connection_PostgresSQL.jpg?fit=max&auto=format&n=IFr-A2MDVJd80FDs&q=85&s=39d3c203f03918cb303701e20ca4f07c" alt="Screenshot of the Create new database page in the FlexiCapture Administration and Monitoring Console with the PostgreSQL option selected, showing the server instance name, database name, and database server authentication fields." width="948" height="652" data-path="images/flexi-capture/DB_new_connection_PostgresSQL.jpg" />
        </Frame>

        To create a PostgreSQL database, the user needs the `CREATEDB`+`CREATEROLE` or `SUPERUSER` role attributes. A user account with the necessary permissions is created automatically, named in the `FCUser12_DatabaseName` format (where `DatabaseName` is the name of the database).
      </Tab>
    </Tabs>
  </Step>

  <Step title="Set up file storage">
    Select the **Use external file storage** option and specify the path to the file storage. The file storage holds binary data such as document images, project settings, and captured data.

    For best performance, place the file storage on the same disk as the Application Server. In enterprise environments, use a fail-safe disk, RAID, or high-performance external storage. Add the file storage to the exceptions of your antivirus software and the Windows Search indexer.

    For more information, including how to run without a file storage, see [Set up a file storage](/flexi-capture/web-stations/monitoring-console/mmc-app-serv-storage).
  </Step>

  <Step title="Test the connection">
    Use the **Test Connection** button to check the entered values. If the test is successful, click **OK**.

    If you encounter authentication problems when testing the connection, make sure that **Mixed Authentication Mode** ("SQL Server and Windows authentication") is enabled for Microsoft SQL Server.

    <Frame>
      <img src="https://mintcdn.com/abbyy/IFr-A2MDVJd80FDs/images/flexi-capture/DB_connection.png?fit=max&auto=format&n=IFr-A2MDVJd80FDs&q=85&s=0401e4b566b699cf8686da5213bd315a" alt="Screenshot of the Application server Current settings page in the FlexiCapture Administration and Monitoring Console, showing the MS SQL server instance name, database name, and file storage path with Apply Patch, Connect to Existing Database, and Create New Database buttons." width="1053" height="673" data-path="images/flexi-capture/DB_connection.png" />
    </Frame>
  </Step>
</Steps>

## After you create the database

Once the database is created, the user name and a temporary password are displayed. The temporary password is the word `password`.

<Note>
  The user must change the temporary password on the login page (`https://<ApplicationServer>/FlexiCapture12/Login`, where `<ApplicationServer>` is the name of the computer on which the Application Server is installed). After changing it, the user is redirected to the Administration and Monitoring Console.
</Note>

The user who creates the database automatically becomes an Administrator. An Administrator can:

* Change the Application Server settings
* Upload projects
* Grant access permissions for projects
* Create users and manage their roles and permissions
* Grant the Administrator role to another user and delegate further configuration of the system

The user who creates the database cannot be stripped of the Administrator role.

## What happens when the database is created

1. **A FlexiCapture 12 database is created.** The account used depends on the authentication method:

   * **Server authentication** – the account specified on the **Settings → Application Server → Connect to Existing Database / Create New Database** page.
   * **Windows authentication** – the account under which the browser displaying the Application Server runs.

   This account runs `Description.sql`, which creates the database, and then `DBInitFill.sql`, which populates it with data. Both scripts are in `<IIS Root Directory>\FlexiCapture12\Server` (the default is `C:\inetpub\wwwroot`). The `Upgrade*.sql` files in the same folder are not used for database creation.
2. **A Database Server account is added.** This is the account under which the FlexiCapture 12 Web Services application pool runs on the Application Server (Network Service by default).
3. **The step 2 account is granted `db_owner` permissions** on the `FlexiCapture12` database from step 1. The Application Server uses the step 2 account for all further interaction with the database, so you can delete the step 1 account if it is no longer needed.

## Database permissions and privileges

### Microsoft SQL Server

When creating a new database:

* `CREATE ANY DATABASE` (required to create a new database)
* `SECURITYADMIN` (required to create a new user under whose account the Application Server is running)

When connecting to an existing database:

* `EXECUTE ON SCHEMA::DBO`
* `SELECT ON SCHEMA::DBO`

When installing patches, connecting to, and using the database:

* `DB_DATAREADER`
* `DB_DATAWRITER` (DBInitFill)
* `DB_DDLADMIN`
* `ALTER ON DATABASE::<DB_NAME>` (required for specifying the recovery model and enabling Snapshot isolation)
* `EXECUTE ON SCHEMA::DBO`
* `GRANT EXECUTE ON SCHEMA::DBO`
* `DB_BACKUPOPERATOR` (required for creating backups and restoring the database)
* `DB_ACCESSADMIN` (required for adding users to the database)
* `DB_SECURITYADMIN` (required for managing database permissions)

### Oracle

Oracle database users need the following privileges to work with the database and install patches:

* `CONNECT`
* `CREATE SESSION`
* `CREATE TABLE`
* `CREATE VIEW`
* `CREATE SEQUENCE`
* `CREATE PROCEDURE`
* `CREATE TYPE`
* `CREATE TRIGGER`
* `EXECUTE ON SYS.DBMS_LOCK`

### PostgreSQL

Creating a PostgreSQL database works the same way as creating a Microsoft SQL database, but the user must have one of the following privileges:

* `CREATEDB+CREATEROLE`
* `SUPERUSER`
