4. Connecting to Databases: SQL Server, MySQL, DirectQuery and Live Connection
4.5 Connecting to MySQL
Many start-ups and web apps store orders in MySQL. Power BI Desktop has a built-in MySQL connector, pan it needs a driver.
Steps in Power BI
- Install the driver first. Download and install MySQL Connector/NET (Oracle's ADO.NET driver) from the official MySQL website. Use a version that the current Microsoft documentation lists as supported for the MySQL connector. Restart Power BI Desktop after installing.
- Home › Get data › More… › Database › MySQL database › Connect.
- Server:
qc-mysql.example.com:3306(orlocalhost:3306); Database:quickcommerce. - Optional Advanced options: Command timeout, SQL statement, Include relationship columns, Navigate using full hierarchy.
- Credentials: choose Database, enter the MySQL user (e.g.
pbi_reader) and password › Connect. - Select tables in the Navigator › Transform Data.
- For scheduled refresh through a gateway, install the same driver on the gateway machine too.
MySQL-style SQL for the same Maharashtra filter (note the backticks and LIMIT):
SELECT o.order_id, o.order_datetime, s.city, s.area, o.amount, o.delivery_time_mins
FROM `orders` o
JOIN `dark_store` s ON s.store_id = o.store_id
WHERE s.city IN ('Pune','Solapur','Nashik','Sambhaji Nagar','Kolhapur','Nagpur')
ORDER BY o.order_datetime DESC
LIMIT 1000;
| Error message (typical) | Likely cause | Fix |
|---|---|---|
| This connector requires one or more additional components to be installed | MySQL Connector/NET is missing | Install the driver and restart Desktop |
| Unable to connect to any of the specified MySQL hosts | Wrong server/port, server down, firewall blocks port 3306 | Check server:port, ask the admin to open the port or allow your IP |
| Access denied for user 'pbi_reader'@'…' | Wrong password, or the user is not allowed from your machine/host | Reset the password, ask the admin to grant access from your host |
| SSL/TLS or certificate errors | Server requires/does not support encryption | Ask the admin about SSL settings |
| Works in Desktop, fails in the Service | Driver not installed on the gateway, or credentials not set on the gateway connection | Install the driver on the gateway and configure the connection |
Import vs DirectQuery for MySQL
Simple bhashet sangaycha tar, check the current Microsoft documentation for which connectivity modes the MySQL connector supports. Most MySQL reports use Import mode with scheduled refresh.
Practice task
Install MySQL Community Server locally, create tables orders and dark_store with ten rows each (Pune and Solapur stores), connect from Power BI, and deliberately type the wrong port to see the error message.
Ravindra Bagale's Tip
The error that comes up most often with MySQL is a missing or wrong-version driver. Install the MySQL Connector/NET version Microsoft's documentation asks for, restart Power BI Desktop, and use server:port only if the port is not the default 3306. A driver missing on the gateway machine causes the same error in scheduled refresh. It's very simple – just make it a habit.
Ravindra Bagale's Tip – मराठी
MySQL मध्ये सगळ्यात जास्त येणारी error म्हणजे driver नसणं किंवा चुकीच्या version चा driver. Microsoft च्या documentation मध्ये सांगितलेलं MySQL Connector/NET version install करा, Power BI Desktop restart करा, आणि port default 3306 नसेल तरच server:port वापरा. Gateway machine वर driver नसेल तर scheduled refresh मध्ये पण हीच error येते. एकदम simple आहे, फक्त सवय लावून घ्या.
Ravindra Bagale's Tip – हिंदी
MySQL में सबसे ज़्यादा आने वाली error है driver का न होना या गलत version का driver. Microsoft के documentation में बताया गया MySQL Connector/NET version install करो, Power BI Desktop restart करो, और port default 3306 न हो तभी server:port लिखो. Gateway machine पर driver न हो तो scheduled refresh में भी यही error आती है. बहुत आसान है, बस आदत बना लो.