🏥
Pharmacy Management System
Complete MySQL Server Setup, Workbench Configuration, Database Initialization & Software Installation Manual
1. System Introduction & Prerequisites
This manual provides exhaustive, step-by-step instructions to set up the Pharmacy Management System (PharmacyMS) and its target database environment. The system utilizes a robust multi-tiered architectural schema built on top of a MySQL Database Server to manage pharmacy operations, secure salaries, transactions, and discount card engines.
💡 System Architecture Highlight
PharmacyMS is fully self-contained. It packages all required .NET runtimes, library dependencies, and security engines. You do not need to install the .NET 8.0 SDK on client computers. You only need to ensure a target MySQL Server is accessible locally or over the network.
Minimum Prerequisites:
- Operating System: Windows 10 or Windows 11 (64-bit).
- Database Server: MySQL Community Server 8.0 or newer.
- Database Tool: MySQL Workbench (for schema administration).
- Port Access: Default port
3306 open on the database host.
2. MySQL Database Server Setup
To run the database locally or on a server, you must install the MySQL Server engine.
Step 1.1
Download and Install MySQL Server
- Navigate to the official MySQL downloads site: https://dev.mysql.com/downloads/installer/
- Select the MySQL Installer Web Community or full offline installer package.
- Run the downloaded MSI installer.
- In the installation dashboard, select "Custom" or "Server only". For a full administration setup, choose "Developer Default" (this automatically bundles MySQL Server, MySQL Shell, and MySQL Workbench).
- Click "Execute" to download and install all selected packages.
Step 1.2
Server Configuration & Security Setup
- Type and Networking: Under "Server Configuration Type", select "Development Computer" if installing locally, or "Server Computer" if installing on a central dedicated machine. Ensure "TCP/IP" is checked and the Port is set to
3306.
- Authentication Method: Select "Use Strong Password Encryption for Authentication (RECOMMENDED)".
- Accounts and Roles (Root Password):
- Set a strong password for the
root administrative user.
- Write this password down securely. You will need this root password to configure the database connections, execute the schema, and create users.
- Windows Service: Ensure "Configure MySQL Server as a Windows Service" is enabled. Set the Service Name to
MySQL80 (or appropriate version) and check "Start the MySQL Server at System Startup".
- Click "Execute" to apply the configurations. The service will verify, start, and remain active in the background.
3. Workbench Configuration & Database Schema Initialization
Using MySQL Workbench, we will establish administrative access, initialize the pharmacy database, execute the structural schema, and provision the initial administrator account.
Step 2.1
Creating an Administrative Connection
- Launch MySQL Workbench from your Windows Start Menu.
- Click the "+" icon next to "MySQL Connections" to add a new connection.
- Configure the Connection profile:
- Connection Name:
Localhost Admin
- Connection Method:
Standard (TCP/IP)
- Hostname:
127.0.0.1 (or database server IP address)
- Port:
3306
- Username:
root
- Click "Store in Vault..." and enter the secure
root password defined during server configuration.
- Click "Test Connection". Upon receiving a "Successfully made the MySQL connection" banner, click "OK".
Step 2.2
Creating the Database and Schema Execution
You must initialize the database structure before the pharmacy app can begin operations. While the app can auto-generate missing fields, running the verified production schema ensures optimal database constraints.
- Open the newly created "Localhost Admin" connection in Workbench.
- In the top SQL Query Editor tab, execute the following SQL to create a clean database schema named
pharmacy_db:
CREATE DATABASE IF NOT EXISTS `pharmacy_db`
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
- Now, we will load the complete database tables structure. In the Workbench top menu, go to File > Open SQL Script...
- Select the verified script file: Pharmacy_db.sql
- Ensure the target database is set by selecting
pharmacy_db, or add this directive at the very top of your SQL Editor:
USE `pharmacy_db`;
- Click the **Lightning Bolt icon** ⚡ (or press
Ctrl+Shift+Enter) to execute the complete schema. The output console at the bottom will log a succession of successful table creations.
Step 2.3 - CRITICAL
Provisioning the Initial Administrator User
The system validates user logins using a secure SHA-256 Base64 hashing algorithm. To enable the very first login into the application dashboard, you must manually insert one root administrative user. The credential mapping for this initial user is:
| Username |
Desired Password |
SHA-256 Base64 Hash Value (Stored in DB) |
Assigned Role |
| admin |
admin |
jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg= |
Admin |
Execute this exact SQL query inside your MySQL Workbench editor to provision this initial account:
INSERT INTO `pharmacy_db`.`users`
(`username`, `password_hash`, `full_name`, `role`, `salary`, `phone`, `email`, `is_active`)
VALUES
('admin', 'jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg=', 'Administrator', 'Admin', 0.00, '1234567890', 'admin@pharmacy.com', 1);
💡 Security Note
Once you successfully launch the system, it is highly recommended to navigate to the Employee Directory or Profile Settings inside the UI and change this default password to something stronger. The UI automatically handles the secure SHA-256 normalization and Base64 hashing on save.
4. Creating a Dedicated App Database User
It is a severe security vulnerability to connect your daily desktop application using the administrative root credential. Instead, we will configure a dedicated user in Workbench that is restricted to the specific database.
Step 3.1
Creating User and Granting Localhost & Network Privileges
- Inside MySQL Workbench, in the left navigation sidebar under "Administration", click "Users and Privileges".
- Click "Add Account" at the bottom of the pane.
- On the "Login Limits" tab, configure:
- Login Name:
pharmacy_user
- Authentication Type:
Standard
- Limit to Hosts Matching:
% (This wildcard allows connections from any host on the network. If the server and application are on the same machine, you can set this to localhost or 127.0.0.1 for absolute security).
- Password / Confirm Password: Choose a strong application password (e.g.,
PharmSecurePass2026).
- Click "Apply" at the bottom-right.
- Select the "Schema Privileges" tab at the top.
- Click "Add Entry...". Select the radio button "Selected Schema" and choose
pharmacy_db from the list. Click "OK".
- In the privileges list, click "Select All" to grant standard operational permissions (
SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, etc.).
- Click "Apply". The dedicated user is now active and isolated to the pharmacy database schema.
5. Software Installation & Setup Wizard
Now that the database environment is fully prepared, you can proceed to install the Pharmacy Management System on the client computer.
Step 4.1
Running the Installer Setup
- Locate the compiled installer file:
PharmacyMS_Setup.exe
- Double-click the installer to launch the modern installation wizard.
- Select a custom target directory if desired (Default:
C:\Program Files\PharmacyMS).
- Check the option to "Create a Desktop Shortcut" to ensure easy access for active cashier terminals.
- Click "Install". The installer will unpack the files and compile native binaries.
- Once completed, check "Launch Pharmacy Management System" and click "Finish".
Step 4.2
Executing the First-Time Configuration Wizard
Upon the system's very first launch, it will detect that no settings file exists and will automatically open the First-Time Setup Wizard. Fill in the parameters across the three configuration panels:
Panel 1: Database Setup
- Host / Server:
127.0.0.1 (if local) or the server's IP address on the local network.
- Port:
3306 (standard MySQL port).
- Database Name:
pharmacy_db.
- Username:
pharmacy_user (the dedicated application user created in Section 4).
- Password: Enter the password assigned to
pharmacy_user (e.g., PharmSecurePass2026).
- Click "Test Connection". The app will attempt to ping the server. If successful, you will receive an "Successfully connected to the database!" prompt. Click **Next** to proceed.
Panel 2: Pharmacy Profile
- Pharmacy Name: Enter your registered business name (e.g.,
Central Care Pharmacy). This is printed at the top of customer receipt papers.
- Contact Phone: Enter your primary pharmacy phone number.
- Address: Enter the physical branch location. This is printed on invoice logs.
- Click **Next**.
Panel 3: SMTP & Admin Configurations
- Admin Email: Enter the manager's secure email address (e.g.,
manager@pharmacy.com).
⚠️ Critical Rule
The Admin Email is highly vital. In the event of a software lockout (e.g., subscription expiry or license trigger), the app automatically encrypts the unlock token and emails it. If the Admin Email is missing or wrong, unlocking the system will require manual developer database intervention.
- Admin Phone: Branch manager's phone number.
- SMTP Config (Optional): If you want the system to email monthly sales digests or stock warnings automatically to your manager:
- Enter SMTP Server (e.g.,
smtp.gmail.com) and Port (e.g., 587).
- Enter SMTP Username and Password.
- Enable "Use SSL / TLS Encryption".
- Enter Sender Email and Sender Name.
- Click "Test SMTP Settings" to verify delivery.
- Click "Save & Launch".
🚀 Ready for Operation
The system will now load the main application login screen. Enter admin as username and admin as password to gain full access to the Pharmacy Management System! Congratulations on a successful installation.