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
- Power BI Desktop on Windows (it does not run on macOS).
- MySQL Connector/NET installed on the same machine. Microsoft's documentation for the MySQL connector lists Oracle's Connector/NET as a prerequisite; without it Power BI shows "This connector requires one or more additional components to be installed". Download it from the MySQL website and restart Power BI after installing.
- The host name and port of the server (3306 by default), and the database name.
- A MySQL user that is allowed to connect from your computer and can read the tables.
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_id | order_date | city | category | product_name | qty | line_revenue |
|---|---|---|---|---|---|---|
| 1001 | 2026-11-01 | Indore | Displays | 27-inch Monitor | 1 | 13499.00 |
| 1001 | 2026-11-01 | Indore | Accessories | Wireless Mouse | 2 | 1398.00 |
| 1002 | 2026-11-01 | Bhopal | Accessories | USB-C Hub | 1 | 2199.00 |
| 1004 | 2026-11-02 | Nagpur | Accessories | USB-C Hub | 2 | 4398.00 |
| 1004 | 2026-11-02 | Nagpur | Accessories | Wireless Mouse | 1 | 699.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
- Open Power BI Desktop and click Get data > More..., search for MySQL database, and click Connect.
- Enter the Server (for example
localhost,192.168.1.20ordb.example.com:3307for a non-default port) and the Database (shop). - Optionally open Advanced options and paste a SQL statement if you want Power BI to import a query result instead of whole tables.
- When asked for credentials, choose Database, enter
pbi_readerand its password, and connect. - 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:
| city | revenue |
|---|---|
| Indore | 14897.00 |
| Nagpur | 5097.00 |
| Bhopal | 2199.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 symptom | Usual 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 users | Old connector versions do not support the default caching_sha2_password plugin. Update Connector/NET. |
| Refresh is very slow | Power 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
- Import from views, not raw tables, so the business rules live in one place.
- Keep numeric money columns as
DECIMALin MySQL and Fixed Decimal in Power BI. - Add a date table in Power BI for time intelligence; do not rely on
order_datealone. - Index the columns your views filter and join on; see optimising MySQL queries.
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.