---
sidebar_position: 4
title: "Database Setup"
---

# Database Setup

---

# Step 5 — Install Microsoft SQL Server 2012 and SSMS

## 5.1 — Install SQL Server 2012

1. Obtain the SQL Server 2012 installer (`SQLEXPR_x64_ENU.exe`) from:
	- [Gitea release assets](http://145.239.66.197:3000/othmane/team-resources/releases/tag/SQLEXPR_x64_ENU)
	- [Microsoft](https://www.microsoft.com/en-us/download/details.aspx?id=56042)
2. Run the installer and choose **New SQL Server stand-alone installation**.
3. On the **"Database Engine Configuration"** screen, under **Authentication Mode**, select **Mixed Mode** (SQL Server Authentication and Windows Authentication).
4. Set the **SA account password** when prompted. Use the team standard password: `Root123456`.
5. Complete the installation.

## 5.2 — Enable TCP/IP and Port 1433

SQL Server disables TCP/IP by default on fresh installations. The application needs it to connect.

1. Open **SQL Server Configuration Manager** (search for it in the Start menu).
2. Expand **SQL Server Network Configuration → Protocols for MSSQLSERVER**.
3. Right-click **TCP/IP** → **Enable**.
4. Double-click **TCP/IP** → go to the **IP Addresses** tab → scroll to **IPAll** → set **TCP Port** to `1433`.
5. Click **OK**.

## 5.3 — Enable the SQL Server Browser Service

1. In **SQL Server Configuration Manager**, go to **SQL Server Services**.
2. Right-click **SQL Server Browser** → **Properties** → **Service** tab → set **Start Mode** to **Automatic**.
3. Right-click **SQL Server Browser** → **Start**.

## 5.4 — Restart the SQL Server Service

1. In **SQL Server Services**, right-click **SQL Server (MSSQLSERVER)** → **Restart**.

## 5.5 — Configure the Windows Firewall

1. Open **Windows Defender Firewall with Advanced Security** (search in Start menu).
2. Click **Inbound Rules → New Rule**.
3. Select **Port → TCP → Specific local ports: `1433`**.
4. Select **Allow the connection**.
5. Apply to all profiles (Domain, Private, Public).
6. Name the rule `SQL Server 1433` and click **Finish**.

## 5.6 — Create the Application Database Login

1. Install **SQL Server Management Studio (SSMS)**. Download from [Microsoft](https://aka.ms/ssmsfullsetup).
2. Open SSMS and connect to your local instance:
	- Server name: `localhost`
	- Authentication: **SQL Server Authentication**
	- Login: `sa`
	- Password: `Root123456`
	  
> 📝 **Note — Check your `database.properties` before proceeding.**
>
> Open your `database.properties` file and check the value of `db.username`.
> - If it is **`sa`**, skip steps 3–9 entirely. The `sa` account already exists and was configured with the correct password (`Root123456`) during installation. No new login needs to be created.
> - If it is **any other username**, continue with steps 3–9 below to create that login.

3. In **Object Explorer**, expand **Security → Logins**.
4. Right-click **Logins → New Login**.
5. Set the login name and password to match what is in `database.properties` (provided by your team lead).
6. On the **General** page, make sure **Login** status at the bottom is set to **Enabled** (this is the default, but confirm it is not set to Disabled).
7. On the **Status** page, under **Login**, confirm it is set to **Enabled** and under **Permission to connect to database engine**, confirm it is set to **Grant**.
8. On the **Server Roles** page, check **`dbcreator`** and **`public`**.
9. Click **OK**.

---

# Step 6 — Restore the Test Database

1. Download the Stock project test database backup file from the [Gitea release assets](http://145.239.66.197:3000/othmane/team-resources/releases/tag/life_07-04-2026).
2. Open **SSMS** and connect to your local SQL Server instance.
3. In **Object Explorer**, right-click **Databases → Restore Database…**
4. Select **Device** as the source, click **…** (Browse), then click **Add** and navigate to the downloaded `.bak` file. Click **OK**.
5. The backup details will populate in the **Backup sets to restore** grid. Confirm the correct entry is checked.
6. Click **OK** to restore. A success dialog will appear when complete.
7. In **Object Explorer**, right-click **Databases → Refresh**. The `TrizStockLife` database should now appear.
8. Verify the application login created in Step 5.6 has access:
	- Expand **TrizStockLife → Security → Users**
	- If your application login is not listed, right-click **Users → New User**, and map the login to this database with the **`db_owner`** role.
