DEV Community

Cover image for Connecting Power BI to SQL Databases: A Complete Guide to Local SQL Server and Aiven PostgreSQL with SSL
Mistry Khateyi
Mistry Khateyi

Posted on

Connecting Power BI to SQL Databases: A Complete Guide to Local SQL Server and Aiven PostgreSQL with SSL

Introduction

Microsoft Power BI is among the strongest Business Intelligence (BI) solutions of the moment. It helps businesses turn data into actionable information with interactive reports and dashboards.
One of the best features of Power BI is that it can seamlessly integrate with a vast range of data sources, including SQL databases on premises or in the cloud. Cloud-hosted databases are more secure and additional security measures like SSL encryption are required for connecting to a local database, whereas it is relatively simple to connect to a local one.
In this tutorial, I will show you how to connect to Power BI:

  • A Local SQL Server Database
  • An Aiven PostgreSQL Cloud Database. This is a Secure SSL Configuration for Cloud Connectivity.

At the end of this guide, you will be able to securely connect Power BI to local and cloud databases and start leveraging Power BI to create rich analytics solutions.

Prerequisites

Before you start, you need to have the following:

  1. Microsoft Power BI Desktop
  2. SQL Server, for local connections to the database.
  3. Aiven PostgreSQL database
  4. DBeaver -optional, for testing database connection
  5. Access to your machine for administrative purpose.
  6. Internet connectivity.

Architecture Overview

Power BI Desktop
       │
       ▼
SQL Database
(Local SQL Server)
Enter fullscreen mode Exit fullscreen mode

For cloud connectivity:

Power BI Desktop
       │
       ▼
 SSL Encryption
       │
       ▼
Aiven PostgreSQL
       │
       ▼
Cloud Database
Enter fullscreen mode Exit fullscreen mode

in this section, you will be using a local SQL Server database to connect to Power BI.For this part, you will be using a local SQL Server database to connect to Power BI.

Part 1: Connecting Power BI to a Local SQL Server Database

Step 1: Launch Power BI Desktop.

Open Power BI Desktop, and click on.
A specific object on the local network. An entity on the local network, such as a SQL Server Database.
Power BI offers two types of connections:
Import Mode. Imports data into power BI.

Benefits:

  • Faster report performance
  • Offline analysis
  • Optimized visualizations

DirectQuery Mode.will retrieve information from the source database each time a report is refreshed.

Benefits:

  • Real-time data access
  • Works with large databases
  • Reduced storage requirements

Step 2:Enter Server Details

Provide:

  • SQL Server Name
  • Database Name (Optional)

Example:

Server: DESKTOP-SQL01
Database: SalesDB
Enter fullscreen mode Exit fullscreen mode

Then CLICK OK.

Step 3: Authenticate

Choose the appropriate authentication method:

  • Windows Authentication
  • Database Authentication
  • Microsoft Account

Once authenticated, you will be able to see the tables and views that are available in Power BI.

Step 4: Select and Load Data.

Choose the appropriate tables.

Preview the data. Click Load.

Power BI takes the selected data and processes it for reporting and visualization.

In this part, we will connect Power BI to our Aiven PostgreSQL Database.In this part we will connect Power BI to our Aiven PostgreSQL Database.
When using cloud databases, you need to ensure that there is encrypted communication between the client and the database server.
PostgreSQL connections are secured with SSL certificates in Aiven.

Part 2: Connecting Power BI to an Aiven PostgreSQL Database

Unlike local SQL Server, cloud databases require encrypted communication between the client and the server.
Aiven secures all PostgreSQL connections using SSL encryption.

Step 1: Get the information of the database connection.

Log in to your Aiven Console, and go to your PostgreSQL service.
The Connection Information page includes the following:

  • Database Name
  • Host
  • Port
  • Username
  • Password
  • SSL Mode
  • Service URI

These information will be utilized when setting up Power BI.

In this screenshot below, you can see a PostgreSQL connection string for Aiven. In this screenshot you can see an Aiven PostgreSQL connection string.

The settings above are the PostgreSQL connection settings that have been provided by Aiven. Such credentials are needed to create a secure connection from Power BI.

Step 2: Downloading CA Certificate.
Click into the Connection Information page and you will see the CA Certificate section below.
Download the certificate file of the application.

The CA certificate is used to identify the PostgreSQL server, and to create a trusted encrypted connection.
Now the SSL Certificate needs to be imported, for this.

Step 3.Open the certificate that is downloaded.

Open the certificate that is downloaded.

Start the Certificate Import Wizard.

Choose:

  • Current User or Local Machine
  • Trusted Root Certificate Authorities

Complete the installation process.

The Certificate Import Wizard is displayed. The Certificate Import Wizard appears.

The certificate installation guarantees that Windows will trust the Aiven PostgreSQL server and won't generate any SSL validation errors.

Step 4: Check the Connection with DBeaver

Check that the database is accessible prior to connection with Power BI.

Launch Open DBeaver and connect to the PostgreSQL instance.

Validate:

  • Successful connection
  • Database availability
  • Table accessibility
  • Data visibility

In this section, the user will verify the database using Dbeaver.Now, user will verify the database in Dbeaver.

Step 5: Connect Power BI

Open Power BI Desktop.

Select:

The first arrow is from Home to Get Data. The first arrow is from Home to SQL Server Database.

or

This is an example of a data source.This is an example of data source postgresql database.

Depending on your configuration.

Enter:

  • Server Name
  • Database Name

Choose:

  • Import
  • DirectQuery

Click OK.

Now, go to the Power BI Database Connection window by clicking this button. Click this button to open the Power BI Database Connection window.

Use a Power BI Database Connection to connect to a Power BI database. Connect to a Power BI database using a Power BI Database Connection.

This configuration screen is used by Power BI to create a connection to the Aiven PostgreSQL database.

Step 6: Authenticate

Provide:

  • Username
  • Password

If asked, enable SSL.

Power BI will create a safe and secure encrypted connection to the cloud database.

Step 7: Load Data into Power BI

After authentication:
First, pick the tables to which you want to add attributes.

  1. Preview the data.
  2. Click Load.

New data is now available on:

  • Dashboards
  • Reports
  • KPIs
  • Data Modeling
  • Interactive Visualizations.

Why SSL Matters

Data between Power BI and the database is encrypted with SSL.
Benefits include:

  • Data confidentiality
  • Protection against interception
  • Server authentication

The ability to adhere to security protocols. Security standard compliance.

  • Secure cloud communication

If not using SSL, sensitive data could be revealed in transit.

Aiven PostgreSQL vs Local SQL Server

Database type Local SQL Server Aiven PostgreSQL
Hosting On-Premises Cloud
Internet Required No Yes
Clear Text Optional Required
Scalability Limited by Hardware Highly Scalable
Plan Construction Operation
Data is available on local network Data is available to global access
Manually configured Manual Built-in

Troubleshooting Tips

SSL Certificate Error
Ensure the CA certificate has been imported into the Trusted Root Certification Authorities store.
Authentication Failed

Verify:

Username
Password
Database name
Unable to Connect

Confirm:

Host name
Port number
Firewall settings
Internet connectivity
No Tables Visible

Check that your database user has permission to access the required schema and tables.

Best Practices
Use SSL for all cloud database connections.
Store credentials securely.
Keep Power BI Desktop updated.
Test database connectivity using DBeaver before connecting Power BI.
Use Import mode for better performance unless real-time data is required.
Regularly refresh datasets to keep reports up to date.

Conclusion

Connecting Power BI to SQL databases is a fundamental skill for data professionals. While local SQL Server databases offer a simple setup, cloud-hosted platforms such as Aiven provide scalability, high availability, and enhanced security through SSL encryption. By following the steps outlined in this guide, you can confidently establish secure connections, validate your database using DBeaver, and import data into Power BI for interactive reporting and analytics.

Whether you're working on personal projects, academic assignments, or enterprise business intelligence solutions, understanding both local and cloud database connectivity will strengthen your data analysis skills and prepare you for real-world scenarios.

Top comments (2)

Collapse
 
leslie_angu_ profile image
leslie angu

Thank you for writing such an insightful article with key points highlighted. The usage of visualize illustrated broke the text monotony. SSL in full secure sockets layer.

Collapse
 
sirphilip profile image
PHILIP KAPLONG

This is a very insightful article