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. MySQL up and running
The database is created,



djangoproject database



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.










share|improve this question
























  • 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















up vote
0
down vote

favorite












I have created the database on XAMPP mysql which is up and running. MySQL up and running
The database is created,



djangoproject database



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.










share|improve this question
























  • 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













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. MySQL up and running
The database is created,



djangoproject database



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.










share|improve this question















I have created the database on XAMPP mysql which is up and running. MySQL up and running
The database is created,



djangoproject database



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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












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'
}
}





share|improve this answer





















  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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'
}
}





share|improve this answer





















  • 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















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'
}
}





share|improve this answer





















  • 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













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'
}
}





share|improve this answer












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'
}
}






share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()