I have a Django application that is running just fine on two other servers. It is using MySQL as the database.
I have the user setup for a new instance of the application on a new server so that I can successfully connection via the mysql command line client to the remote database.
However, when I attempt to run ./manage.py syncdb, it tell me:
django.db.utils.OperationalError: (1045, "Access denied for user 'app_user'#'mynewserver.com' (using password: YES)")
Every place I've looked online tell me to make sure the user is setup in mysql and has permission to the new database and even to run flush privileges;. I have double checked all of those and done this multiple times. That doesn't seem to be the issue.
Any thoughts?
EDIT
Also, I just checked and running the following from the python command line works fine too:
conn = mysql.connect(host='mynewserver.com', user='app_user', passwd='secret', db='myapp').cursor(mysql.cursors.DictCursor)
EDIT 2
I just ran ./manage.py sql myapp > myapp.sql; ./manage.py dbshell < myapp.sql
Everything worked, it created the tables just fine. I'm assuming that would use the same permissions and settings as running ./manage.py syncdb. What gives?!?
Versions
Python==2.7.6
Django==1.6.1
EDIT 3
I guess I should also add that I am using South==0.7.6. If that helps.
I did leave something out that I didn't think was relevant, but is totally relevant.
This application has multiple databases defined. Syncdb only runs on one database at a time, and by default will run using the default database, as noted here:
https://docs.djangoproject.com/en/1.6/topics/db/multi-db/#synchronizing-your-databases
However, when my user didn't have permission on the other database syncdb would fail. It didn't indicate which database it was trying to access.
Running ./manage.py reset_db from django-extensions, worked fine as well, before I made sure that the user had permissions on all databases.
I would assume then that there is a bug in syncdb. After more looking into this, I might have to report a bug to Django.
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 am doing this task the first time. I have found good documentation on how to download an existing postgres DB to local but none of the informations seem to work for me.
I need to download an existing postgres DB to local. I do this to check the entries and to have a backup because I need to work on the DB.
I have posgresql installed localy and I want to copy the heroku DB into my local DB which is named postgres. The local server has a username postgres and a password.
I have only one DB and one APP on heroku.
I tried 2 solutions.
PG:PULL
heroku pg:pull DATABASE_URL postgres
This gave me:
DL is deprecated, please use Fiddle
! The command "createdb" is written either false or
! could not be found
!
! Unable to create new local database. Ensure your local Postgres is working and try again.
So I tried with password ans username:
PGUSER=postgres PGPASSWORD=mypw heroku pg:pull DATABASE_URL postgres
This gave me:
The command "PGUSER" is written either false or could not be found
PG:BACKUPS
heroku pg:backups capture
This worked well:
Use Ctrl-C at any time to stop monitoring progress; the backup
will continue running. Use heroku pg:backups info to check progress.
Stop a running backup with heroku pg:backups cancel.
DATABASE ---backup---> b003
Backup completed
Then I used curl:
curl -o latest.dump `heroku pg:packups public-url`
Which gave me:
The command "curl" is written either false or could not be found
It seems nobody had such a problem, I dont know what I am missing. I red the whole heroku documentation and there is no such case.
EDIT
I connected to my DB via PgAdmin4 but also here I am getting the same type of error when trying to restore a DB dump file.
The PgAdmin4 log gives me:
The command "pg_restore.exe" is written either false or could not be found
I also tried to add postgresql to global path variable, but it does not seem to help:
;C:\Programme\PostgreSQL\9.6\bin\pg_restore.exe
and I tried:
;C:\Programme\PostgreSQL\9.6\bin
I am trying to install Odoo on a hosted machine. First, I created a new Postgres user "odoo" with database "odoo". Then, I cloned the GIT repositry "https://github.com/odoo/odoo". After that I ran:
./openerp-server -s -c server.cfg
This created a configuration file named "server.cfg". I edited the configuration by changing the database parameters. After that, I ran
./openerp-server -c server.cfg
This loaded all the necessary addons and the server started running.
Whenever I open the browser, I keep getting to the following url:
http://erp.example.com/web/database/selector?error=Unable%20to%20login%20on%20database%20odoo
I thought maybe this is a database error. So, I checked the database and all the tables are created in the database.
The database user and password created all the tables but for some reason I can't login to the database.
Has anyone had an issue like this? If yes, how did you fix it?
Maybe you don't set a password for your database yet, if it's the case: do it with this query :
ALTER USER odoo WITH ENCRYPTED PASSWORD '<type your password here>';
or : run odoo in the debug mode for see some details about the problem :
try this command
python openerp-server -r odoo -w '<the password>' --db_port=<5432 by default> --debug
I've got some code (using Python 3.4, Django 1.7, and PostgreSQL) that I pushed to Heroku. Everything worked fine until I added a login. Just like on my local machine, I used the shell to add a user, create a password, and save the user/password. That pattern worked locally, even with foreman.
The setup that seems to have worked:
heroku run python3 manage.py shell
a = User.objects.get(id=1)
a
The server returns
<User: {'username':'Me'}>.
Asking for a.password returns a hashed password that changes when I do a.set_password('Blah') and then a.save().
That's all good and normal, except that the username/password (unhashed) won't log me in. When I run:
heroku run python3 manage.py changepassword Me
Heroku responds with:
CommandError: user 'Me' does not exist
How can a user be saved and retrievable in the shell, implying it's in the database, but not be found otherwise using "manage.py changepassword"?
Most importantly, how can I log into my website on Heroku?
****Edit****
I ran python manage.py createsuperuser in the Heroku shell to create a user so I could log in. Once I did, I saw that none of my CSS loaded. I'm not sure how that's related, but two big problems at the same time make me suspicious that it's something totally unrelated.
I started to use Python Anywhere today. I created the database MySQL following the instructions. The problem is I can't do a simple manage.py syncdb because I get access denied error for my user 'irgmedeiros' in my mysql database. I can't grant privileges to my user neither create another user with privileges. How to solve it? Couldn't find solution in their forum and I'm waiting a answer from email. Anybody experienced this before?
Some possible troubleshooting steps:
check the server address - mysql.server
double-check the password - is it the same as the one you configured on the pythonanywhere MySQL config screens
double-check the database name - this follows the format username$database_name
check if you can open a normal mysql console, firstly from the MySQL tab, and then manually in a bash shell with
.
mysql -u my_username -h mysql.server -p
[edit] - the final solution was:
* double-check the database name - this follows the format username$database_name
don't forget that username$ folks!