Step-by-step tutorial to connect Python to MySQL using XAMPP. Includes sample connection script, MySQL setup guide, and troubleshooting tips.
This beginner-friendly project shows you how to connect Python to a MySQL database running locally through XAMPP. It's perfect for data analysts, students, and developers building real-time dashboards or data apps.
- How to install and run MySQL using XAMPP
- How to create a MySQL database using phpMyAdmin
- How to connect Python to MySQL with
mysql-connector-python
- How to troubleshoot common connection issues
Make sure you have:
- Python 3.x
- XAMPP
mysql-connector-python
(install withpip install mysql-connector-python
)
- Make sure MySQL is running in your XAMPP control panel
- Create a database in phpMyAdmin (e.g.
sales_dashboard_mysql
) - Update your connection info in
connect.py
if needed - Run the script:
Use this to run the code in your terminal: python connect.py
✅ Connected to MySQL successfully!
📺 Tutorial Video
⭐️ Like this project? Give it a ⭐️ and share with others who are learning Python + SQL!
☕Enjoying the Content? Support the channel here: https://buymeacoffee.com/datageekismyname in this beginner-friendly tutorial, I’ll show you how to connect Python to a MySQL database using XAMPP. This is a key step for building real-time dashboards, running data analysis, or creating full applications using your local database.
What You’ll Learn : • Install and run MySQL using XAMPP • Create a MySQL database using phpMyAdmin • Write a simple Python script to connect to MySQL
✅ Perfect for data analysts, developers, or students learning Python and SQL.
📦 Tools: Python, MySQL, XAMPP, mysql-connector-python
📺 Coming up next: Build a real-time dashboard using Streamlit + MySQL!
🔔 Don’t forget to LIKE & SUBSCRIBE for more Python & Data Analysis tutorials! Subscribe here: https://www.youtube.com/@datageekismyname
☕Enjoying the Content? Support the channel here: https://buymeacoffee.com/datageekismyname Or Link to donate on paypal: https://www.paypal.com/donate/?hosted_button_id=ZCL24X55R9C5G