# Import database on cPanel (shared hosting)

Use this guide to import the eVisa database into MySQL on your cPanel shared hosting.

## File to import

- **`evisa_system_cpanel_import.sql`** – Full database dump (all tables, data, triggers, routines). Compatible with MySQL 5.7+ and MariaDB.

---

## Step 1: Create database and user in cPanel

1. Log in to **cPanel**.
2. Open **MySQL® Databases**.
3. Create a new database, e.g. `youruser_evisa` (cPanel often prefixes with your username).
4. Create a MySQL user and set a strong password.
5. Add the user to the database with **ALL PRIVILEGES**.

Note the **database name**, **username**, and **password** for `.env` on the server.

---

## Step 2: Import the SQL file

### Option A: phpMyAdmin (easiest)

1. In cPanel, open **phpMyAdmin**.
2. Select your database (e.g. `youruser_evisa`) in the left sidebar.
3. Go to the **Import** tab.
4. Click **Choose File** and select **`evisa_system_cpanel_import.sql`** (upload it first via File Manager or FTP if needed).
5. Leave options as default. Click **Go**.
6. Wait until you see a success message.

### Option B: SSH + command line

If you have SSH access:

```bash
# Upload the .sql file to your account first (e.g. via SFTP or File Manager).
# Then run (replace with your cPanel MySQL user and database name):

mysql -u youruser_dbuser -p youruser_evisa < evisa_system_cpanel_import.sql
```

Enter the MySQL password when prompted.

---

## Step 3: Laravel .env on cPanel

In your backend `.env` on the server, set:

```env
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=youruser_evisa
DB_USERNAME=youruser_dbuser
DB_PASSWORD=your_mysql_password
```

Use the exact database name and username from cPanel (often with prefix).

---

## Step 4: Hosting layout (Vercel + cPanel)

- **Frontend (Next.js)** → Vercel  
  - Set env var: `NEXT_PUBLIC_API_URL=https://your-cpanel-api-domain.com/api`
- **Backend (Laravel)** → cPanel  
  - Document root: `public` folder of the Laravel app
  - Same `.env` with the DB_* values above and `APP_URL` / `FRONTEND_URL` set to your Vercel URL and cPanel API URL as needed.

After import, run on the server (e.g. via SSH or cPanel “Run PHP script” / terminal):

```bash
cd /path/to/your/laravel/backend
php artisan config:cache
php artisan route:cache
```

No need to run `migrate` or `db:seed` if you imported this full dump.
