This guide shows you how to import a .sql file into a PostgreSQL database using phpPgAdmin in cPanel. The process involves uploading your SQL file through the web interface, which then executes the queries against your selected database.

How to import the .sql file

  1. Step 1: Access phpPgAdmin

    Log in to your cPanel account and open the phpPgAdmin tool. You can find this under the "Databases" section of your cPanel dashboard.

  2. Step 2: Connect to PostgreSQL server

    In the left-hand tree menu, click on the PostgreSQL link. This will list all the databases you have access to under this server. Click on the database name to log in and manage it. You may be prompted to enter your cPanel username and password for authentication.

  3. Step 3: Select your database

    Once logged in, you will see a list of databases on the left-hand side. Click on the name of the database where you want to import data. After selecting the database, look for the "SQL" tab or button at the top of the page and click it to open the SQL query window.

  4. Step 4: Provide the SQL content

    In the SQL query window, you have two options:

    • (a) If your .sql file is small and you prefer to paste it directly, open the file in a text editor like Notepad (Windows) or TextEdit (Mac), copy the content, and paste it into the SQL query field provided.
    • (b) For larger files, it's more efficient to upload the .sql file. Click on the "Browse" button next to the "File" input field in phpPgAdmin. Navigate to the location of your .sql file on your computer, select it, and click "Open." The file path should now appear in the input field.
  5. Step 5: Execute the import

    After selecting or pasting your SQL content, click the "Execute" or "Run" button at the bottom of the page. phpPgAdmin will process and execute the queries contained in your .sql file against the selected PostgreSQL database. You can monitor the progress and any error messages directly on this page.

Tips:
Before importing a large .sql file, ensure that your server's timeout settings are configured to allow sufficient time for the import process to complete without interruption. If you encounter errors during the import, review them carefully as they can provide clues about what went wrong (e.g., syntax issues in the SQL script or insufficient permissions). It's also a good practice to back up your existing database before performing an import operation.