#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
MySQL Tutorial · Data Analytics

How to Connect MySQL with Power BI for Dashboards

Short version: in Power BI Desktop choose Get data > MySQL database, type the server and database name, sign in with a MySQL user, pick your tables, and load. In practice most failed attempts break before that, on a missing driver or a database user that cannot connect. This guide covers the preparation on the MySQL side, the connection steps, and the errors you are likely to see.

What you need before you start

Step 1: prepare MySQL for reporting

Do not connect a dashboard as root. Create a read-only user:

CREATE USER 'pbi_reader'@'%' IDENTIFIED BY 'Str0ng#Passw0rd';
GRANT SELECT ON shop.* TO 'pbi_reader'@'%';
SHOW GRANTS FOR 'pbi_reader'@'%';
Grants for pbi_reader@%
GRANT USAGE ON *.* TO `pbi_reader`@`%`
GRANT SELECT ON `shop`.* TO `pbi_reader`@`%`

'%' allows connections from any host; replace it with your office IP or subnet if you can. Next, give Power BI a clean, report-ready shape instead of raw tables. A view joins the tables and removes rows the dashboard should never count. Sample data for a small electronics store:

CREATE TABLE products (product_id INT PRIMARY KEY, product_name VARCHAR(40), category VARCHAR(20));
CREATE TABLE orders (order_id INT PRIMARY KEY, order_date DATE, city VARCHAR(20), status VARCHAR(10));
CREATE TABLE order_items (order_id INT, product_id INT, qty INT, unit_price DECIMAL(10,2),
                          PRIMARY KEY (order_id, product_id));

INSERT INTO products VALUES (1,'Wireless Mouse','Accessories'), (2,'USB-C Hub','Accessories'),
                            (3,'27-inch Monitor','Displays');
INSERT INTO orders VALUES (1001,'2026-11-01','Indore','delivered'), (1002,'2026-11-01','Bhopal','delivered'),
                          (1003,'2026-11-02','Indore','cancelled'), (1004,'2026-11-02','Nagpur','delivered');
INSERT INTO order_items VALUES (1001,1,2,699), (1001,3,1,13499), (1002,2,1,2199),
                               (1003,3,1,13499), (1004,1,1,699), (1004,2,2,2199);

CREATE VIEW v_sales_lines AS
SELECT o.order_id, o.order_date, o.city, p.category, p.product_name, oi.qty,
       oi.qty * oi.unit_price AS line_revenue
FROM orders o
JOIN order_items oi ON oi.order_id = o.order_id
JOIN products p     ON p.product_id = oi.product_id
WHERE o.status <> 'cancelled';

SELECT * FROM v_sales_lines ORDER BY order_id, product_name;
order_idorder_datecitycategoryproduct_nameqtyline_revenue
10012026-11-01IndoreDisplays27-inch Monitor113499.00
10012026-11-01IndoreAccessoriesWireless Mouse21398.00
10022026-11-01BhopalAccessoriesUSB-C Hub12199.00
10042026-11-02NagpurAccessoriesUSB-C Hub24398.00
10042026-11-02NagpurAccessoriesWireless Mouse1699.00

The cancelled order 1003 is already excluded, so nobody building visuals can forget the filter. More on views in the MySQL views tutorial.

Step 2: connect from Power BI Desktop

  1. Open Power BI Desktop and click Get data > More..., search for MySQL database, and click Connect.
  2. Enter the Server (for example localhost, 192.168.1.20 or db.example.com:3307 for a non-default port) and the Database (shop).
  3. Optionally open Advanced options and paste a SQL statement if you want Power BI to import a query result instead of whole tables.
  4. When asked for credentials, choose Database, enter pbi_reader and its password, and connect.
  5. In the Navigator, tick shop.v_sales_lines (and any other tables you need). Click Transform Data to check data types in Power Query, or Load to import straight away.

After loading, a quick check: a table visual of city with the sum of line_revenue should match the same query in MySQL:

cityrevenue
Indore14897.00
Nagpur5097.00
Bhopal2199.00

Reconciling one number against SQL before building ten charts saves a lot of embarrassment in the review meeting.

Step 3: keep the data fresh

Imported data is a snapshot. In Desktop, Refresh re-runs the queries. Once you publish the report to the Power BI service, scheduled refresh needs a route to your database: for a MySQL server inside an office network or on your laptop, that means installing the on-premises data gateway on a machine that can reach MySQL (with Connector/NET installed there as well) and adding the data source in the gateway settings. Connector capabilities, such as which storage modes are supported, change between Power BI releases, so check Microsoft's current MySQL connector page before you design around DirectQuery.

Errors you are likely to see

Message or symptomUsual cause and fix
"requires one or more additional components"Connector/NET is missing, or installed after Power BI was opened. Install it and restart Power BI.
"Unable to connect to any of the specified MySQL hosts"Wrong host or port, MySQL listening only on 127.0.0.1 (bind-address), or a firewall blocking 3306.
"Access denied for user"Wrong password, or the user exists only as 'pbi_reader'@'localhost' while you connect from another machine.
Authentication errors with MySQL 8 usersOld connector versions do not support the default caching_sha2_password plugin. Update Connector/NET.
Refresh is very slowPower BI imports every column of every selected table. Select only needed columns in a view or a SQL statement and pre-aggregate large fact tables.

Good habits

Related reading: the same connection in Tableau is covered in how to connect MySQL with Tableau, dashboard design in building dashboards with MySQL data, and Power BI itself in a beginner's guide to learning Power BI.

Become a Job-Ready Data Analyst

Master MySQL, Advanced Excel, Power BI, Tableau and Python with Uncodemy's Data Analytics Training in Noida — live projects, expert mentors and Dedicated Placement Support.

Enroll in Data Analytics Course →