I'm using a tutorial to install MongoDB on the raspberry pi: http://notejs.com/?p=252
I have followed the instructions with complete success up till the line:
Connect to an instance:
mongo
I then get an error like this:
-bash: mongo: command not found
I have followed this tutorial step by step, the only difference is that I downloaded, compiled and installed MongoDB in a folder that isn't the home folder, could this be the problem?
edit: MongoDB is apparently running already when I enter the command:
sudo /etc/init.d/mongod start
So it's not the case that it's too much for my PI
The instructions have this section for making the mongod binary part of your path, which is why that is working:
sudo ln -s /opt/mongo/bin/mongod /usr/bin/mongod
But they do not do the same for the mongo shell binary. Hence you just need to do the same thing for the that binary, that is:
sudo ln -s /opt/mongo/bin/mongo /usr/bin/mongo
Alternatively you could add /opt/mongo/bin to your $PATH variable, or just call /opt/mongo/bin/mongodirectly.
Related
I'm starting my coding journey and I have set up the Ubuntu terminal(WSL2). I followed this guide my cousin gave me and it included some directions to install PostgreSQL. I thought it would be a good idea to get it ahead of time, but now it's turning into a nightmare. I installed it and followed the directions to make it automatically connect to the server on the Ubuntu terminal start-up. Long story short, it makes the terminal take awhile to start-up, puts my terminal in some weird directory, and I won't even be using it, so we decided to get rid of it. We tried everything and finally decided to just uninstall it. Now on start-up, it's still trying to connect to the server or whatever. I tried running the code to make it automatically start-up again in case it might just toggle it on and off, but now it's attempting to connect three times on open. Please see the directions I used below as well as what my terminal is showing on start-up. Also, when I try commands to end it or whatever, it can't do it because postgresql can't be found (because I uninstalled it). Any thoughts?
Directions:
In a few weeks, we'll talk about SQL and Databases and you'll need something called PostgreSQL, an open-source robust and production-ready database.
Let's install it now.
sudo apt install -y postgresql postgresql-contrib libpq-dev build-essential
sudo /etc/init.d/postgresql start
sudo -u postgres psql --command "CREATE ROLE `whoami` LOGIN createdb;"
You can configure PostgreSQL to autostart, so you don't have to execute sudo /etc/init.d/postgresql start each time you open a new terminal:
sudo echo "`whoami` ALL=NOPASSWD:/etc/init.d/postgresql start" | sudo tee /etc/sudoers.d/postgresql
sudo chmod 440 /etc/sudoers.d/postgresql
echo "sudo /etc/init.d/postgresql start" >> ~/.zshrc
Error Code:
sudo: /etc/init.d/postgresql: command not found
sudo: /etc/init.d/postgresql: command not found
sudo: /etc/init.d/postgresql: command not found
➜ /home
Just remove the offending line from .zshrc.
Let me add that the Linux emulation of Windows cannot be used for serious work with a database, as it does not implement the vital system call fsync to persist data. Any operating system crash will result in data corruption.
I recently started developing with NodeJS. In the course I attend, they gave me steps to install on Mac but it's giving me problems. After a some googling, I understood that macOS Catalina has blocked writing access to the root folder. After that, I spent a day searching on Google and Stack Overflow for solutions to this problem. There were many different solutions, but none of them worked. Some installed, but the mongod command wouldn't work. Even the installation process on MongoDB itself didn't work.
At the end, I decided to use MongoDB Atlas. So in my cluster0, I went to Connect > Connect with mongo shell > I do not have MongoDB installed. They gave some steps to install it with Homebrew. Now, when I type mongo "mongodb+srv://cluster0.hflrg.mongodb.net/<dbname>" --username <myUserName>, it connects to MongoDB Atlas. The mongod command still doesn't work.
Can you tell me a way to install MongoDB on Mac. I have macOS Catalina Version 10.15.5.
Note: I don't have much experience with the terminal, so if possible, please avoid using terms like "Add so and so the you $PATH variable", and try to explain in detail. A huge thanks in advance.
I usually and like to install by downloading .tgz package from MongoDB Community Server, and setting up via command lines.
Download .tgz package from MongoDB Community Server.
Extract the files from the downloaded archive:
tar -zxvf mongodb-macos-*.tgz
Copy binaries in your PATH environment variable:
sudo cp /path/to/the/mongodb-directory/bin/* /usr/local/bin/
Create the data directory:
sudo mkdir -p /usr/local/var/mongodb
IMPORTANT
Starting with macOS 10.15 Catalina, Apple restricts access to the MongoDB default data directory of /data/db. On macOS 10.15 Catalina, you must use a different data directory, such as /usr/local/var/mongodb.
Create the log directory:
sudo mkdir -p /usr/local/var/log/mongodb
Run MongoDB:
mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log
To run mongod in the background, use --fork at the end of command line:
mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log --fork
Helpful links and references:
Installing MongoDB on macOS tarball
MongoDB on macOS Catalina v10.15+
Hope these may help! Have a great one!
Use Homebrew, it uses /usr/local by default.
brew tap mongodb/brew
brew install mongodb/brew/mongodb-community
brew services start mongodb/brew/mongodb-community
mongo --quiet --eval 'db.version()'
4.2.8
This worked for me, but is based on the answer by #Erni_Souza
Download the .tgz package from here MongoDB Community Server.
Extract the files on your machine using tar -zxvf mongodb-macos-*.tgz or just use the default Archive Utility.app on your machine.
Copy the binaries into your /usr/local/bin folder with:
sudo cp /path/to/the/mongodb-directory/bin/* /usr/local/bin/ just as instructed or you can resort to using the ./mongod command via Terminal.app from the folder you extracted into.
Create the data directory mkdir -p ~/data/db
Run mongodb
mongod --dbpath ~/data/db
or with
./mongod --dbpath ~/data/db
if the binaries are still in the directory you extracted them to.
You can check out this link MongoDB on macOS Catalina v10.15+ as given in the answer by #Erni_Souza for more information.
I've tried following the installation instructions laid out here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
But I run into a problem with, I'm guessing, Upstart/initctl and I can't get the mongod service to start other than by running it manually as sudo in a terminal, which is a Bad Idea IMO. (Even if this is merely for a classroom, single-user setup.)
sudo /etc/init.d/mongod start
Yields this error:
initctl: Unknown job: mongod
I've tried sudo initctl reload-configuration and running the above start command again, to no avail.
Any ideas or suggestions on what to do next?
Installing mongodb using what the official documentation doesn't seem to work in crouton. Below are the instructions I followed to get it working on my machine (crouton running elementaryOS)
Download the physical mongodb package for linux (can be obtained from mongodb.org)
Extract the mongodb package using tar -xvzf mongodb-linux-x86_64-2.6.7.tgz
Make the installation directory (sudo mkdir /usr/lib/mongodb)
Copy the extracted mongodb into to /usr/lib/mongodb (sudo mv mongodb-linux-x86_64-2.6.7 /usr/lib/mongodb)
Make the data directory (sudo mkdir -p /data/db)
Start mongodb (sudo /usr/lib/mongodb/mongodb-linux-x84_64-2.6.7/bin/mongod &)
I am using ubuntu 10.10, I installed nodejs from source ( ./configure && make && sudo make install ) and all done successfully. I tried to start nodejs CLI using
node
it says
bash: /usr/sbin/node: No such file or directory
note : i also referred these following questions
Express.js: No Such file or directory,
nodejs vs node on ubuntu 12.04
but still not able to rectify.
never mind, i found node in /usr/local/bin/node.
so the following command made it work.
sudo ln -s /usr/sbin/node /usr/local/bin/node
I have installed PostgreSQL and it is working ok. However, when I went to restore a backup I got the error -bash: psql: command not found:
[root#server1 ~]# su postgres
[postgres#server1 root]$ psql -f all.sql
bash: psql: command not found
[postgres#server1 root]$
What have I done wrong?
export PATH=/usr/pgsql-9.2/bin:$PATH
The program executable psql is in the directory /usr/pgsql-9.2/bin, and that directory is not included in the path by default, so we have to tell our shell (terminal) program where to find psql. When most packages are installed, they are added to an existing path, such as /usr/local/bin, but not this program.
So we have to add the program's path to the shell PATH variable if we do not want to have to type the complete path to the program every time we execute it.
This line should typically be added to theshell startup script, which for the bash shell will be in the file ~/.bashrc.
perhaps psql isn't in the PATH of the postgres user. Use the locate command to find where psql is and ensure that it's path is in the PATH for the postgres user.
The question is for linux but I had the same issue with git bash on my Windows machine.
My pqsql is installed here:
C:\Program Files\PostgreSQL\10\bin\psql.exe
You can add the location of psql.exe to your Path environment variable as
described in this other answer, and shown in the screenshot below:
After changing the above, please close all cmd and/or bash windows, and re-open them (as mentioned in the comments #Ayush Shankar). If you are using an IDE like Visual Studio Code, please close and re-open the entire IDE (as mentioned in the comments #Somraj Chowdhury)
You might need to change default logging user using below command.
psql -U postgres
Here postgres is the username. Without -U, it will pick the windows loggedin user.
It can be due to psql not being in PATH
$ locate psql
/usr/lib/postgresql/9.6/bin/psql
Then create a link in /usr/bin
ln -s /usr/lib/postgresql/9.6/bin/psql /usr/bin/psql
Then try to execute psql it should work.
In case you are running it on Fedora or CentOS, this is what worked for me (PostgreSQL 9.6):
In terminal:
$ sudo visudo -f /etc/sudoers
modify the following text from:
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
to
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/pgsql-9.6/bin
exit, then:
$ printenv PATH
$ sudo su postgres
$ psql
To exit postgreSQL terminal, you need to digit:
$ \q
Source: https://serverfault.com/questions/541847/why-doesnt-sudo-know-where-psql-is#comment623883_541880
If you are using the Postgres Mac app (by Heroku) and Bundler, you can add the pg_config directly inside the app, to your bundle.
bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
...then run bundle again.
Note: check the version first using the following.
ls /Applications/Postgres.app/Contents/Versions/
Check if PostgreSQL is installed or not.
If not you can do the same in ubuntu using this command.
sudo apt update
sudo apt install postgresql postgresql-contrib
there must be two reasons for this either the package is not install or psql is not defined in the PATH
the simple way is to create a link within the /usr/bin or /usr/local/sbin/
First find the the file
sudo find / -name psql
then create soft link
sudo ln -sf /opt/pgpro/1c-14/bin/psql /usr/local/sbin/psql
Sometimes we face this issue when the gem installation command doesn't find the pg client library for various reasons, such as if psql is not in the path.
In those cases, providing the command with the path to pg_config may fix the issue.
gem install pg -v 1.3.5 -- --with-pg-config=/path/to/pg_config
In my case, I faced a similar issue when I installed postgresql#12 with Homebrew in the Rosetta environment.
Following command solved the issue in my case.
gem install pg -v 1.3.5 -- --with-pg-config=/usr/local/Homebrew/Cellar/postgresql#12/12.13/bin/pg_config