Export and import MongoDB - mongodb

I would like to export one Mongo database to another.
But when I run:
mongodump -h ds1sdf4.mlab.com:57064 -d heroku_randomkey -u myuser -p mypassword -o volumes/testdump/mongodb1
Terminal tells me: -bash: mongodump: command not found
Am I doing this all wrong?

You need to install mongo on your system. mongodump is a part of that package. do brew install mongo and try your command again. If you do not have Brew, I suggest you install it from here.

Related

How to run the 'postgres' command (single-user)

I have postgres installed on an ubuntu machine, and I am able to enter into the command line via something along the lines of:
$ sudo -u postgres psql
psql (10.15 (Ubuntu 10.15-0ubuntu0.18.04.1))
Type "help" for help.
postgres=#
And I can start/stop the server by doing something like:
$ sudo service postgresql
Usage: /etc/init.d/postgresql {start|stop|restart|reload|force-reload|status} [version ..]
Those both seem fine. However, I would like to run postgres in single-user mode to do a couple tests. On the postgres page it gives a few examples, such as:
To start a single-user mode server, use a command like
postgres --single -D /usr/local/pgsql/data other-options my_database
However, if I use the 'postgres' command, I just get an error saying I don't have that command:
$ postgres
Command 'postgres' not found, did you mean:
What do I need to install to run the 'postgres' command in order to enter single-user mode?
as you have not export the binary path that's why it's can't find your binary of postgres.
use this command:
/usr/lib/postgresql/10/bin/postgres --single -D /usr/local/pgsql/data other-options my_database
or,
you can export the path in bash
first open the bashrc with this command:nano ~/.bashrc
add this line in the end :PATH="/usr/lib/postgresql/10/bin/:$PATH"
run this command source ~/.bashrc
the just use postgres --single -D /usr/local/pgsql/data other-options my_database
you can also find where your binary is with this command : find /usr/lib -iname 'postgres'
It is already installed, it is just not in your PATH, as it is not anticipated you would use it manually.
It is probably somewhere like "/usr/lib/postgresql/10/bin/postgres", or you can use locate or find to find it.
Ubuntu has conf files spread over several places so:
/usr/lib/postgresql/13/bin/postgres --single -D /var/lib/postgresql/13/main -c "config_file=/etc/postgresql/13/main/postgresql.conf"

sails-inverse-model authentification error on postgresql database

I tried sails-inverse-model on a several postgres DBs on a local VM.
sails-inverse-model -u myPostgresUser -p myPasswd -d myDBname -t pg -m -v -c
And I systematically have an authentification error authentification by Passwd failed for user « myPostgresUser»
Any idea what's wrong or what I dis wrong?
This solved my issue:
C:\Users\[user name]\AppData\Roaming\npm\node_modules\sails-inverse-model\node_modules\pg-json-schema-export
In that folder open package.json and check the dependencies
I changed "pg.js" to "pg": "^7.4.1" as pg.js is deprecated. Save the file and in the same folder and run npm update

How to copy or import database from mongolab.com to my local mongodb server?

I have used some queries for import and export database from mongolab.com to my local mongodb server. Can you please anyone tell me, how to retrieve all data from mongolab.com (clouddb) to local mongodb server.
I have trying these codes in my local mongodb server with command line prompt:
mongodump -h ds040032.mongolab.com:40032 -d mydb -u "<"myname">" -p "<"mypass">" -o "<"D:\2016\LearnMongoDB\NEWDB">"
mongoexport -h ds040032.mongolab.com:40032 -d mydb -c "<"collectionname">" -u "<"myname">" -p "<"mypass">" -o "<"D:\2016\LearnMongoDB\Testingf">"
mongorestore -h ds040032.mongolab.com:40032 -d mydb -u "<"myname">" -p "<"mypass">" "<"input db directory">"
After entering, I am not getting any results with the commandline prompt. Getting Still cursor loading symbol.
try db.copyDatabase
db.copyDatabase('from_mydb','to_mydb','ds040032.mongolab.com:40032',
'<myname>','<mypassword>')
Go to local mongo shell and apply above command with appropriate parameters.
In 2017, db.copyDatabase (using shell) works, but the format has changed a bit:
db.copyDatabase('mlab_databse_name', 'local_folder_for_data_name', 'ds000000.mlab.com:00000', 'database_user_name', 'database_user_password')

Linuxbrew, install postgres and start service automatically

I install Postgresql on my Ubuntu with:
brew install postgres
now I have:
psql --version
psql (PostgreSQL) 9.5.0
How can I start the service automatically?
On my Mac with homebrew I can do it with:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
but how on Ubuntu with Linuxbrew?
I try with:
brew services start postgresql
but it says:
sh: 1: list: not found
Error: Could not read the plist for `postgresql`!
What to do?
Not quite automatic but a step in the right direction. On my system I did the following:
$ pg_ctl start -D $HOME/.linuxbrew/var/postgres -l logfile
You could simple create an alias in your .bash_profile or .bashrc something like:
alias poston="pg_ctl start -D $HOME/.linuxbrew/var/postgres -l logfile"
alias postoff="pg_ctl stop -D $HOME/.linuxbrew/var/postgres"
To test it all out (assuming you do not yet have a database on your machine) you can also create a database for your current user:
$ poston
$ createdb `whoami`
$ psql

MongoDump Command Not Found on AWS EC2 Instance

Inside AWS EC2 Instance, I am trying to import my MongoLab hosted Database using mongodump command.
sudo mongodump -h dsXXXX.mongolab.com:xxxxx -d testDB -u XXXXX -p YYYYYYY -o dumpmongolabs
I get the following error
-bash: mongodump:command not found
I had installed MongoDB like this
echo "[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0" | sudo tee -a /etc/yum.repos.d/10gen.repo
sudo yum -y install mongo-10gen-server mongodb-org-shell
What are we missing exactly?
Cheers and Thanks in Advance.
As noted in the documentation, mongodump is part of the mongodb-org-tools package, which you haven't installed