Skip to content

engoncode/django-mysql-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Establishing MySQL Connection with Django

Introduction

In this chat, we discussed the steps to establish a connection between Django and a MySQL server. The user has a Django development environment on macOS using XAMPP.

Step 1: Django Configuration

  1. Configured the DATABASES settings in settings.py using the django.db.backends.mysql engine.
  2. Specified the database name, user, password, host, port, and UNIX socket option according to the MySQL configuration being used.

MySQL Socket Issue

  1. The user encountered an error related to the incorrect MySQL socket at /tmp/mysql.sock.
  2. Provided the correct MySQL socket location from XAMPP: /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock.

Solution

  1. Updated the socket location in the OPTIONS setting within DATABASES.
  2. Used the python manage.py migrate command to apply the changes.

Checking Connection

  1. Utilized the python manage.py check command to verify the connection to the database.
  2. Employed the Django shell to establish a connection to the database and execute simple queries.

Conclusion

After implementing the suggested solutions, the user successfully established a connection between Django and the MySQL server running on XAMPP. Additionally, the user verified the database connection and confirmed its proper functionality.

This summarizes the discussion in this chat regarding establishing a MySQL connection with Django in a macOS development environment using XAMPP.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages