# 4.5 MySQL ला connect करूया

Source: https://ravindrabagale.com/mr/powerbi/ch04-connecting-to-databases-sql-server-mysql/4-5-connecting-to-mysql.html
Language: mr (Marathi with English technical terms)

अनेक web apps MySQL वापरतात. Power BI मधल्या MySQL connector साठी आवश्यक driver आधी install करावा लागतो.

Official MySQL website वरून MySQL Connector/NET घ्या. चालू Microsoft connector documentation मध्ये supported असलेलं version वापरा. Install नंतर Desktop restart करा.

Home › Get data › More… › Database › MySQL database › Connect निवडा.

Server: qc-mysql.example.com:3306 किंवा localhost:3306. Database: quickcommerce.

गरजेनुसार Command timeout, SQL statement, Include relationship columns आणि Navigate using full hierarchy हे Advanced options वापरा.

Database credentials मध्ये pbi_reader सारखा user आणि password द्या.

Navigator मधून tables निवडा आणि Transform Data करा.

Gateway मार्फत refresh करणार असाल तर gateway machine वरही योग्य driver install करा.

खाली MySQL चं उदाहरण आहे. Backticks आणि LIMIT लक्षात घ्या. ORDER BY सोबत LIMIT असल्यामुळे इथे सर्वांत अलीकडच्या 1000 rows निवडल्या जातात.

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 | संभाव्य कारण | काय तपासायचं?

 | Additional components required | Connector/NET नाही | Driver install करून Desktop restart करा.

 | Unable to connect to MySQL hosts | Server / port चुकीचा, server बंद किंवा firewall | Server:port तपासा; admin कडून network access तपासून घ्या.

 | Access denied for user | Password चुकीचा किंवा host ला परवानगी नाही | योग्य credentials आणि host permissions मागा.

 | SSL/TLS / certificate error | Encryption settings mismatch | Admin सोबत SSL settings तपासा.

 | Desktop चालतं, Service fail | Gateway driver किंवा credentials अपूर्ण | Gateway वर driver व connection configure करा.

MySQL साठी उपलब्ध connectivity modes चालू Microsoft documentation मध्ये तपासा. Import आणि scheduled refresh हा नेहमीचा वापर आहे.

Practice

Local MySQL Community Server मध्ये orders आणि dark_store तयार करा. Pune व Solapur चा test data वापरून प्रत्येकी दहा rows भरा. Connect करा. नंतर फक्त test connection मध्ये चुकीचा port देऊन error कसा दिसतो ते पाहा आणि योग्य port परत द्या.

अधिक माहिती: Microsoft Learn — MySQL connector.

रवींद्र बागले यांची tip

Driver missing किंवा wrong version हा नेहमीचा error आहे. Gateway machine वरही driver लागतो हे विसरू नका. Default port 3306 पेक्षा वेगळा असेल तर योग्य port स्पष्ट द्या.
