Databases configuration

58 views
Skip to first unread message

Cool Smith

unread,
Dec 6, 2018, 2:33:37 PM12/6/18
to Django users
Hi everyone,

I am new to Django. I have started a new project running on my localhost. Rather than using the default sqlite database, I changed it to mysql with the following settings on MacOS High Sierra v13.10.6:

DATABASES = {
   
'default': {
       
'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mysql',
        'USER': 'root',
        'PASSWORD': 'root',
        'HOST': '',
        'PORT': '5432'
    }
}
Enter code here...

When I run the server using the
python manage.py runserver

command, I get an error:
django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")

Does anyone know the cause of this error and tell me how to fix it? Thank you in advance.

C. Kirby

unread,
Dec 6, 2018, 2:38:09 PM12/6/18
to Django users
Did you start your mysql process?

Arnaldo Díaz Molina

unread,
Dec 6, 2018, 3:15:45 PM12/6/18
to django...@googlegroups.com
Did you have installed the mysql driver??? Is your host localhost???
Did you have your mysql service started???
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/693cde12-e701-4f4f-8b51-4938fd0f427b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

Cool Smith

unread,
Dec 7, 2018, 9:09:28 AM12/7/18
to Django users
How to do so?

Cool Smith

unread,
Dec 7, 2018, 9:11:01 AM12/7/18
to Django users
I tried starting MYSQL server on System Preferences. However, it seems the server will shutdown automatically a few seconds later.

Kasper Laudrup

unread,
Dec 7, 2018, 9:22:41 AM12/7/18
to django...@googlegroups.com
Hi Cool Smith,

On 12/7/18 10:11 AM, Cool Smith wrote:
> I tried starting MYSQL server on System Preferences. However, it seems
> the server will shutdown automatically a few seconds later.
>

You would probably have a better chance of getting useful responses if
you posted your question in a forum related to running MySQL on Mac OSX.

Maybe here:

https://forums.mysql.com/

Figuring out how to run processes on Mac OSX is not really related to
using Django.

Kind regards,

Kasper Laudrup

Chuck R

unread,
Dec 7, 2018, 2:27:29 PM12/7/18
to Django users
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mysql',
'USER': 'root',
'PASSWORD': 'root',
'HOST': '',
'PORT': '3306'
}
}

This should work for you. You were using the wrong port.The port you were using is for postgresql.You maybe prompted to install mysqlclient. Use pip install mysqlclient.

Chuck R

unread,
Dec 7, 2018, 2:27:39 PM12/7/18
to django...@googlegroups.com
Hi, if you're using python venv, try install mysqlclient(pip install mysqlclient) and rerun the local server.

--

Daniel M

unread,
Dec 7, 2018, 2:44:33 PM12/7/18
to django...@googlegroups.com
I think the problem is the server. Try pip install mysqlserver then start the server. 

On Dec 7, 2018 17:27, "Chuck R" <seas...@gmail.com> wrote:
Hi, if you're using python venv, try install mysqlclient(pip install mysqlclient) and rerun the local server.

On Thu, Dec 6, 2018, 9:38 AM C. Kirby <mis...@gmail.com wrote:
Did you start your mysql process?

On Thursday, December 6, 2018 at 9:33:37 AM UTC-5, Cool Smith wrote:
Hi everyone,

I am new to Django. I have started a new project running on my localhost. Rather than using the default sqlite database, I changed it to mysql with the following settings on MacOS High Sierra v13.10.6:

DATABASES = {
   
'default': {
       
'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mysql',
        'USER': 'root',
        'PASSWORD': 'root',
        'HOST': '',
        'PORT': '5432'
    }
}
Enter code here...

When I run the server using the
python manage.py runserver

command, I get an error:
django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")

Does anyone know the cause of this error and tell me how to fix it? Thank you in advance.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages