I installed XAMPP on my Mac (Snow Leopard) and installed Django. How do I tell Django to use this and when I fire up python manage.py runserver I get this error:
...
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)")
How do I tell Django to use this instead?
/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
Put that in the HOST entry for the database in the settings.
simple solution is that just install Django Stack for Xampp. Not need to configure any thing every thing is configured already
https://wiki.bitnami.com/Infrastructure_Stacks/BitNami_Django_Stack
Related
I am building a web app using Django. I am trying to connect the app to the Azure Database for PostgreSQL.
When I try to make migrations with the command, python manage.py makemigrations from PowerShell, I'm getting this error:
no pg_hba.conf entry for host
What does this error mean?
This error means you've haven't configured PostgreSQL correctly for the user you are trying to connect from Django with.
pg_hba.conf is the PostgreSQL file which contains PostgreSQL users, where from, and how they are able to connect. See here for more details:
https://www.postgresql.org/docs/12/auth-pg-hba-conf.html
You should get the same error when you try to run any Django command which needs to connect to the database, for example, python manage.py dbshell. Good luck!
I´m trying to connect to a mysql database installed on a virtual machine with Ubuntu Server. I´m very new to server administration so I followed this tutorial LAMP on it. I also followed this tutorial to install phpMyAdmin. Apparently, everything is working fine. I can access to phpMyAdmin from the web browser on my host machine.
The network of the virtual machine is configured as bridge adapter.
The problem is that I cannot connect when using python (also from host machine). This is the code I'm using:
import mysql.connector
cnx = mysql.connector.connect(user='root', password='XXXXX',
host='192.168.1.138',
port=3306,
database='mysql')
cnx.close()
The code returns this error:
DatabaseError: 1130: Host 'desktop-p7v30jj.home' is not allowed to connect to this MySQL server
I looked for information and found that it could be due to the bind-address. So I edited the file /etc/mysql/mysql.cnf and included the following two lines at the end with no success:
[mysqld]
bind-address = 0.0.0.0
What else should I try? Any idea?
Thanks in advance!
I managed to find the solution by simply creating another user, as stated in this topic:
Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server
Sorry for answering.
Regards.
I'm trying to run a server in python/django and I'm getting the following error:
django.db.uils.OperationslError: (200, "Can't connect to local MySQL
server through socket '/tmp/mysql.sock' (2)").
I have MySQL-python installed (1.2.5 version) and mysql installed (0.0.1), both via pip, so I'm not sure why I can't connect to the MySQL server. Does anyone know why? Thanks!
You can't install mysql through pip; it's a database, not a Python library (and it's currently in version 5.7). You need to install the binary package for your operating system.
I am trying to deploy my django app on EC2 and am using RDS(Mysql) as the backend.
However when I try to run gunicorn with this, the server does not respond, and the if I run python manage.py dbshell I get the error:
CommandError: You appear not to have the 'mysql' program installed or on your path.
It seems to be trying to connect to a local server of mysql when I have clearly changed the host setting the Database dict to my RDS deployment
Things I have done for solving this and trouble shooting:
1. I have changed the database settings so that they point to the RDS database.
Both the EC2 and the RDS instance are in the same zone of AWS(read this might have been the issue)
Permission could have been a problem, but I checked by trying to login from my local machine, and I was able to access the mysql commandline on my server.
Checked the database settings which django is picking up at runtime,they are correct.
Install Mysql-python, it would not install without a local installation of Mysql, so googled that , people suggested install libmysqlclient-dev first and then you should be able to install Mysql-python.
Has someone face a similar problem? What am I doing wrong here?
i'm following this tutorial: http://www.programmersbook.com/page/21/Django-Beginner-Tutorial-Part-I/
and I added the database details (running django.db.backends.postgresql_psycopg2) and i added the template dirs. But when i do
./manage.py syncdb
i get:
self.connection = Database.connect(**conn_params)
psycopg2.OperationalError: could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Any suggestions on how i can fix this please?
Before connecting to database you need to install database server, and configure it for any user to access.
If you want just follow tutorial use SQLite -it's most simple to configure.
Otherwise, install database server of your choose, create database, configure access, make sure that connection details are correct, and/or DB server is up and running.
Best way is try to connect to server via command line.