Unable to connect from django to mysql database
up vote
0
down vote
favorite
I have created the database on XAMPP mysql which is up and running.
The database is created,
I am now trying to connect from django with the following connection parameters,
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': "djangoproject",
'USER': 'root',
'PASSWORD': '******',
'HOST': 'localhost',
'PORT': ''
}
}
I am getting the following error when executing python3 manage.py runserver
and python3 manage.py migrate
django.db.utils.OperationalError: (1049, "Unknown database 'djangoproject'")
I have read a solution to create the database from mysql shell using the create database statement. My question is why i am not able to connect to the database already created on XAMPP mysql.
mysql django python-3.x xampp
|
show 3 more comments
up vote
0
down vote
favorite
I have created the database on XAMPP mysql which is up and running.
The database is created,
I am now trying to connect from django with the following connection parameters,
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': "djangoproject",
'USER': 'root',
'PASSWORD': '******',
'HOST': 'localhost',
'PORT': ''
}
}
I am getting the following error when executing python3 manage.py runserver
and python3 manage.py migrate
django.db.utils.OperationalError: (1049, "Unknown database 'djangoproject'")
I have read a solution to create the database from mysql shell using the create database statement. My question is why i am not able to connect to the database already created on XAMPP mysql.
mysql django python-3.x xampp
Do you have multiple mysql instances installed on your computer? If yes, you may be connecting to the wrong one.
– Shadow
Nov 8 at 6:56
@shadow I don't believe I do though i did execute pip3 install mysqlclient.
– Ayubx
Nov 8 at 7:02
2
try connecting with mysql client via command line first. If it works then your django should work. mysql -uroot –p<your_pass> djangoproject If this work fine then issue with django else issue is in mysql. This is just clue to debug your issue and not the solution.
– Sopan
Nov 8 at 7:11
@sopan So i logged in mysql and used 'show databases;' The djangoproject database is not there in the list.
– Ayubx
Nov 8 at 7:22
The databases i see when executing 'show databases;' are information_schema, mysql, performance_schema and sys.
– Ayubx
Nov 8 at 7:32
|
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have created the database on XAMPP mysql which is up and running.
The database is created,
I am now trying to connect from django with the following connection parameters,
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': "djangoproject",
'USER': 'root',
'PASSWORD': '******',
'HOST': 'localhost',
'PORT': ''
}
}
I am getting the following error when executing python3 manage.py runserver
and python3 manage.py migrate
django.db.utils.OperationalError: (1049, "Unknown database 'djangoproject'")
I have read a solution to create the database from mysql shell using the create database statement. My question is why i am not able to connect to the database already created on XAMPP mysql.
mysql django python-3.x xampp
I have created the database on XAMPP mysql which is up and running.
The database is created,
I am now trying to connect from django with the following connection parameters,
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': "djangoproject",
'USER': 'root',
'PASSWORD': '******',
'HOST': 'localhost',
'PORT': ''
}
}
I am getting the following error when executing python3 manage.py runserver
and python3 manage.py migrate
django.db.utils.OperationalError: (1049, "Unknown database 'djangoproject'")
I have read a solution to create the database from mysql shell using the create database statement. My question is why i am not able to connect to the database already created on XAMPP mysql.
mysql django python-3.x xampp
mysql django python-3.x xampp
edited Nov 8 at 7:42
asked Nov 8 at 6:52
Ayubx
37118
37118
Do you have multiple mysql instances installed on your computer? If yes, you may be connecting to the wrong one.
– Shadow
Nov 8 at 6:56
@shadow I don't believe I do though i did execute pip3 install mysqlclient.
– Ayubx
Nov 8 at 7:02
2
try connecting with mysql client via command line first. If it works then your django should work. mysql -uroot –p<your_pass> djangoproject If this work fine then issue with django else issue is in mysql. This is just clue to debug your issue and not the solution.
– Sopan
Nov 8 at 7:11
@sopan So i logged in mysql and used 'show databases;' The djangoproject database is not there in the list.
– Ayubx
Nov 8 at 7:22
The databases i see when executing 'show databases;' are information_schema, mysql, performance_schema and sys.
– Ayubx
Nov 8 at 7:32
|
show 3 more comments
Do you have multiple mysql instances installed on your computer? If yes, you may be connecting to the wrong one.
– Shadow
Nov 8 at 6:56
@shadow I don't believe I do though i did execute pip3 install mysqlclient.
– Ayubx
Nov 8 at 7:02
2
try connecting with mysql client via command line first. If it works then your django should work. mysql -uroot –p<your_pass> djangoproject If this work fine then issue with django else issue is in mysql. This is just clue to debug your issue and not the solution.
– Sopan
Nov 8 at 7:11
@sopan So i logged in mysql and used 'show databases;' The djangoproject database is not there in the list.
– Ayubx
Nov 8 at 7:22
The databases i see when executing 'show databases;' are information_schema, mysql, performance_schema and sys.
– Ayubx
Nov 8 at 7:32
Do you have multiple mysql instances installed on your computer? If yes, you may be connecting to the wrong one.
– Shadow
Nov 8 at 6:56
Do you have multiple mysql instances installed on your computer? If yes, you may be connecting to the wrong one.
– Shadow
Nov 8 at 6:56
@shadow I don't believe I do though i did execute pip3 install mysqlclient.
– Ayubx
Nov 8 at 7:02
@shadow I don't believe I do though i did execute pip3 install mysqlclient.
– Ayubx
Nov 8 at 7:02
2
2
try connecting with mysql client via command line first. If it works then your django should work. mysql -uroot –p<your_pass> djangoproject If this work fine then issue with django else issue is in mysql. This is just clue to debug your issue and not the solution.
– Sopan
Nov 8 at 7:11
try connecting with mysql client via command line first. If it works then your django should work. mysql -uroot –p<your_pass> djangoproject If this work fine then issue with django else issue is in mysql. This is just clue to debug your issue and not the solution.
– Sopan
Nov 8 at 7:11
@sopan So i logged in mysql and used 'show databases;' The djangoproject database is not there in the list.
– Ayubx
Nov 8 at 7:22
@sopan So i logged in mysql and used 'show databases;' The djangoproject database is not there in the list.
– Ayubx
Nov 8 at 7:22
The databases i see when executing 'show databases;' are information_schema, mysql, performance_schema and sys.
– Ayubx
Nov 8 at 7:32
The databases i see when executing 'show databases;' are information_schema, mysql, performance_schema and sys.
– Ayubx
Nov 8 at 7:32
|
show 3 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
You've missed the port. By default, MySQL is listening to 3306
:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': "djangoproject",
'USER': 'root',
'PASSWORD': '******',
'HOST': 'localhost',
'PORT': '3306'
}
}
Thank you, tried that. Did not work. Fyi i just installed XAMPP and created the database there. I did not install mysql separately.
– Ayubx
Nov 8 at 7:29
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You've missed the port. By default, MySQL is listening to 3306
:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': "djangoproject",
'USER': 'root',
'PASSWORD': '******',
'HOST': 'localhost',
'PORT': '3306'
}
}
Thank you, tried that. Did not work. Fyi i just installed XAMPP and created the database there. I did not install mysql separately.
– Ayubx
Nov 8 at 7:29
add a comment |
up vote
0
down vote
You've missed the port. By default, MySQL is listening to 3306
:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': "djangoproject",
'USER': 'root',
'PASSWORD': '******',
'HOST': 'localhost',
'PORT': '3306'
}
}
Thank you, tried that. Did not work. Fyi i just installed XAMPP and created the database there. I did not install mysql separately.
– Ayubx
Nov 8 at 7:29
add a comment |
up vote
0
down vote
up vote
0
down vote
You've missed the port. By default, MySQL is listening to 3306
:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': "djangoproject",
'USER': 'root',
'PASSWORD': '******',
'HOST': 'localhost',
'PORT': '3306'
}
}
You've missed the port. By default, MySQL is listening to 3306
:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': "djangoproject",
'USER': 'root',
'PASSWORD': '******',
'HOST': 'localhost',
'PORT': '3306'
}
}
answered Nov 8 at 7:14
Giorgos Myrianthous
3,70421235
3,70421235
Thank you, tried that. Did not work. Fyi i just installed XAMPP and created the database there. I did not install mysql separately.
– Ayubx
Nov 8 at 7:29
add a comment |
Thank you, tried that. Did not work. Fyi i just installed XAMPP and created the database there. I did not install mysql separately.
– Ayubx
Nov 8 at 7:29
Thank you, tried that. Did not work. Fyi i just installed XAMPP and created the database there. I did not install mysql separately.
– Ayubx
Nov 8 at 7:29
Thank you, tried that. Did not work. Fyi i just installed XAMPP and created the database there. I did not install mysql separately.
– Ayubx
Nov 8 at 7:29
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53202746%2funable-to-connect-from-django-to-mysql-database%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you have multiple mysql instances installed on your computer? If yes, you may be connecting to the wrong one.
– Shadow
Nov 8 at 6:56
@shadow I don't believe I do though i did execute pip3 install mysqlclient.
– Ayubx
Nov 8 at 7:02
2
try connecting with mysql client via command line first. If it works then your django should work. mysql -uroot –p<your_pass> djangoproject If this work fine then issue with django else issue is in mysql. This is just clue to debug your issue and not the solution.
– Sopan
Nov 8 at 7:11
@sopan So i logged in mysql and used 'show databases;' The djangoproject database is not there in the list.
– Ayubx
Nov 8 at 7:22
The databases i see when executing 'show databases;' are information_schema, mysql, performance_schema and sys.
– Ayubx
Nov 8 at 7:32