Mongo won't allow me to backup my databases - python

I have a new pc and am trying to migrate over my mongodbs.
On my old pc I'm using 3.2.10 and 3.4 on the new one.
I thought the best method would be to simple back and restore on the new pc, however when I try and use the command 'mongodump'
I just get the error message:
2017-01-14T16:29:47.416+0900 E QUERY [thread1] ReferenceError: mongodump is not defined :
#(shell):1:1

you're running mongodump inside mongo but it's part of mongo commands! so exit mongo-cli and run it in bash!

Related

Python Won't Run Even Through It Is In the Path

I have a SQL Server Agent job that executes some python scripts using CmdExec. Everything is set up with a proxy account as expected.
When I run the job I get:
Message
Executed as user: domain\proxyaccount. 'python' is not recognized as an internal or external command, operable program or batch file. Process Exit Code 1. The step failed.
I'm using Anaconda and Python is in the system PATH variable. When I run python from command line, it works. When I run python cutting and pasting the specific command from the job, it works. When I use runas to mimic the proxy account it works. The only place Python doesn't run is form inside the job.
What else do I need to look at to trouble shoot this issue?
You should restart SQL Server Agent after you installed Python on the server.
It is necessary for SQL Server Agent to load new environment variables, including the updated PATH with Python in it.
There are also suggestions to restart SQL Server too, but I believe restarting SQL Server Agent will be enough.

Mysql fails to run after reboot using crontab

I have made a script which saves data to Mysql database using mysqldp and python. When I run script from console (python myscript.py) it works, but when I run it on reboot using Crontab I get an email with following error:
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
When I try to run the script using Crontab not on reboot, but accordingly to time I don't get following error.
Maybe you have some ideas?
What if I would call the same script with while(1) loop once and once again (It will start the new background task every time)?
Thanks to Shadow's hint I have solved the problem.
I just have started the Mysql server manually from the script and now it works.
I have used this command to start the server
from subprocess import call
call(['sudo','service','mysql','start'])

Heroku download postgres DB - capture works, curl is unknown

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

Django, MySQL, syncdb: Access Denied to valid user

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.

Can't connect mongodb after ubuntu-precise server restart

I am developing a web scraping project on Ubuntu server of 25GB hard disk space. I am using python scrapy and mongodb
Last night my harddisk is full because of scraping 60,000 web pages. so mongodb has put a lock and i am unable to access my database it shows this error
function (){ return db.getCollectionNames(); }
Execute failed:exception: Can't take a write lock while out of disk space
So i removed all data stored in /var/lib/mongodb and run "rebbot" command from shell to restart server
When I try to run mongo on command line, I get this error:
MongoDB shell version: 2.4.5
connecting to: test
Thu Jul 25 15:06:29.323 JavaScript execution failed: Error: couldn't connect to
server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
exception: connect failed
Guys please help me so that i can connect to mongodb
The first thing to do is to find out whether MongoDB is actually running. You can do that by running the following commands on the shell:
ps aux | grep mongo
And:
netstat -an | grep ':27017'
If neither of those has any output, then MongoDB is not running.
The best way to find out why it doesn't start is to look in the log file that MongoDB creates. It is usually located at /var/log/mongodb/mongodb.log and it should tell you why MongoDB refuses to start.

Categories