I got an illegal instruction when installing mongoDB when trying to check the version - database

Hey so I tried installing mongoDB and I can't get it to install correctly. I am installing it on wsl on a windows computer and I keep getting illegal instruction when I try to check the version and it won't let me finish installing it. Here are the instructions I used to install MongoDB (version 5.0) on WSL (Ubuntu 20.04):
Open your WSL terminal (ie. Ubuntu) and go to your home directory: cd ~
Update your Ubuntu packages: sudo apt update
Import the public key used by the MongoDB package management system: wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
Create a list file for MongoDB: echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
Reload local package database: sudo apt-get update
Install MongoDB packages: sudo apt-get install -y mongodb-org
Confirm installation and get the version number: mongod --version
Make a directory to store data: mkdir -p ~/data/db
Run a Mongo instance: sudo mongod --dbpath ~/data/db
Check to see that your MongoDB instance is running with: ps -e | grep 'mongod'
To exit the MongoDB Shell, use the shortcut keys: Ctrl + C

Related

Zsh: Command Not found : mongo After trying to install mongodb 4.2 using brew

I have tried the following steps to install and setup mongodb in my mac from here https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/ but I got the following error when running the final "mongo" command in my terminal:
Error Message - Zsh: Command Not found : mongo
This error msg occurred after trying to install mongodb 4.2 using brew
sudo chown -R $(whoami) $(brew --prefix)/*
then
brew tap mongodb/brew
then
brew install mongodb-community#4.2
and
brew services start mongodb-community#4.2
or
mongod --config /usr/local/etc/mongod.conf
then
ps aux | grep -v grep | grep mongod
and
mongo
running brew services start mongodb-community#4.2 returns:
Successfully started `mongodb-community#4.2` (label: homebrew.mxcl.mongodb-community#4.2)
running ps aux | grep -v grep | grep mongod returns:
9081 0.2 0.5 5528024 41856 ?? S 3:01pm 0:01.48 /usr/local/opt/mongodb-community#4.2/bin/mongod --config /usr/local/etc/mongod.conf
7613 0.0 0.1 4298832 5600 s000 T 2:47pm 0:00.08 vim /usr/local/etc/mongod.conf
running mongod --config /usr/local/etc/mongod.conf returns:
zsh: command not found: mongod
There are also no mongo files in my /usr/local/bin directory after using these commands
I created a data/db folder in my /usr/local/bin directory using the following commands:
sudo mkdir -p /usr/local/bin/data/db
sudo chown -R `id -un` /usr/local/bin/data/db
Running "brew update" returns:
brew update
Updated 1 tap (homebrew/cask).
==> Updated Casks
brave-browser
brew install mongodb-community-shell
Fixed the problem for me.
Solved it by manually installing the mongodb community files and db tools using the website instead. Then copying them into /usr/local/bin. Then ignoring the app permissions whenever calling mongo or related commands in the terminal through System Preferences > Security & Privacy > General.
After googling I found out that mongoimport and the other features have to be installed separately: https://www.mongodb.com/try/download/database-tools
Followed by copying those bin files after extracting them into the same /usr/local/bin directory
Not sure why its' not working through homebrew though
This worked for me, I was having same issue on mongodb-community#4.4
brew reinstall mongodb-community#4.4
On terminal something like this will appear during reinstallation.
copy highlighted path with echo
echo 'export PATH="/opt/homebrew/opt/mongodb-community#4.4/bin:$PATH"' >> ~/.zshrc
Now open another terminal and start mongodb services
brew services restart mongodb/brew/mongodb-community#4.4
write mongo on terminal and here we fly
If you installed the mongodb via Homebrew. Need to add the mongo path in your bash_profile.
Edit the bash_profile vi ~/.bash_profile
Add the below line in EOF export PATH=$PATH:/usr/local/opt/mongodb-community#4.2/bin
After the edit bash_profile. Close all terminals and open them again. mongo command start works.
In addition to #ramesh-babu-t-b 's answer, https://stackoverflow.com/a/68407530/1279516, the issue could also be that your MongoDB installation did add mongod to your path, but the installation happened within the current shell session, and so your shell doesn't have the updates to the PATH variable yet.
In this case, only his last step is still necessary - Open a new console window and retry the mongod command.

RHEL 8 Container MSSQL ODBC Driver e2fsprogs

I'm trying to build a custom docker container using the RHEL 8 UBI. As part of this I want to install the MSSQL 17 ODBC driver.
I've followed the steps outlined in Microsofts Documentation here:
https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#redhat17
And added the Microsoft repo to my yum.repos.d directory however when I try to build the container I get the following error: nothing provides e2fsprogs needed by msodbcsql17-17.6.1.1-1.x86_64
When I dug a bit further into this it looks as though it looks as though for RHEL-7 Microsoft suggest installing e2fsprogs manually you can see that here: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#offline-installation
This unfortunately isn't possible in RHEL-8 as e2fsprogs-static has been removed: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/considerations_in_adopting_rhel_8/index#removed-packages_changes-to-packages
The full output from the build is:
$ docker build -f ./test.dockerfile -t daark:1 .
Sending build context to Docker daemon 25.77MB
Step 1/7 : FROM registry.redhat.io/ubi8/ubi
---> a1f8c9699786
Step 2/7 : RUN curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/mssql-release.repo
---> Using cache
---> 90b3e1514239
Step 3/7 : RUN yum search odbc
---> Using cache
---> b26f78d0da28
Step 4/7 : RUN yum search msodbcsql17
---> Using cache
---> c6f7751b97dc
Step 5/7 : ENV ACCEPT_EULA=Y
---> Using cache
---> 2b0003944673
Step 6/7 : RUN yum install -y unixODBC unixODBC-devel
---> Using cache
---> 1d0b8c594905
Step 7/7 : RUN yum install -y msodbcsql17
---> Running in 67c30e75fb42
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:08:11 ago on Wed Aug 5 09:36:32 2020.
Error:
Problem: cannot install the best candidate for the job
- nothing provides e2fsprogs needed by msodbcsql17-17.6.1.1-1.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
The command '/bin/sh -c yum install -y msodbcsql17' returned a non-zero code: 1
This error is pretty reproducible here is the test dockerfile i'm using to debug
FROM registry.redhat.io/ubi8/ubi
RUN curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/mssql-release.repo
RUN yum search odbc
RUN yum search msodbcsql17
ENV ACCEPT_EULA=Y
RUN yum install -y unixODBC unixODBC-devel
RUN yum install -y msodbcsql17
Has anyone managed to get this ODBC driver installed on an RHEL 8 UBI based container?
I found a work around that I hope will help the next person to hit this.
Rather than running yum install -y msodbcsql17 I instead used yum to download the RPM
yum download -y msodbcsql17
then used rpm -Uvh --nodeps msodbcsql17*rpm to install it.
You can use this docker file:
FROM registry.redhat.io/ubi8/ubi
RUN curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/mssql-release.repo
RUN yum search odbc
RUN yum search msodbcsql17
ENV ACCEPT_EULA=Y
RUN yum install -y unixODBC unixODBC-devel
RUN yum download -y msodbcsql17
RUN rpm -Uvh --nodeps msodbcsql17*rpm
#daark thank you for posting your solution. Your solution got me over the problem I was facing. I ended modifying your solution to the following (in case it helps anyone else):
FROM registry.access.redhat.com/ubi8/python-38
USER root
RUN yum update --assumeyes && \
yum install --assumeyes \
unixODBC-devel \
&& yum clean all
RUN curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/mssql-release.repo
RUN yum download -y msodbcsql17
RUN ACCEPT_EULA=y rpm -Uvh --nodeps msodbcsql17*rpm
I tried to add this to the #daark's solution as a comment, but it was too difficult to display the code properly.
Good luck to anyone else facing this issue šŸ€
Latest msodbcsql17 release fixes this issue. The documentation steps work smooth once again. See docs issue
I can confirm that installation on redhat/ubi8 works with msodbcsql17-17.8.1.2-1.x86_64.rpm.
FROM redhat/ubi8
COPY msodbcsql17-17.8.1.2-1.x86_64.rpm /tmp
RUN MSSQL_PID=Developer ACCEPT_EULA=Y yum -y localinstall /tmp/msodbcsql17-17.8.1.2-1.x86_64.rpm; rm /tmp/msodbcsql17-17.8.1.2-1.x86_64.rpm

Install Adminer on Ubuntu 18.04 bionic

I'm trying to install Adminer from Ubuntu repository using:
sudo apt install adminer
Installation works fine but can't find the file /etc/adminer/apache.conf to use with Apache server. The folder /etc/adminer/ is empty and can't find it anywhere with find command.
Any help?
Thanks in advance.
In the next few steps, I'll show you how I installed adminer for Ubuntu 18.04.1 LTS .
After installation with apt package manager change into the adminer directory.
cd /usr/share/adminer
There you will find a file called compile.php.
Run the following command and the adminer-X.X.X.php (X.X.X for your version) file will be created.
sudo php compile.php
Create the apache adminer configuration file.
sudo echo "Alias /adminer.php /usr/share/adminer/adminer-X.X.X.php" | sudo tee /etc/apache2/conf-available/adminer.conf
Now you'll need to activate the configuration.
cd /etc/apache2/conf-available/
sudo a2enconf adminer.conf
Reload your apache webserver.
sudo systemctl reload apache2.
Test in your browser of choice (localhost/adminer.php)
This source was really helpful:
https://www.linuxhelp.com/how-to-install-adminer-on-ubuntu-16-04/
Install Apache:
sudo apt-get install apache2
Install PHP:
sudo apt-get install php libapache2-mod-php php-mysql
Install Adminer:
sudo wget "http://www.adminer.org/latest.php" -O /var/www/html/adminer.php
Once the installation completes, restart Apache.
sudo service apache2 restart
At this point, the setup is complete. You can access Adminer at the following address.
http://[SERVER_IP]/adminer.php

How to connect MSSQL in Laravel homestead?

I am trying to connect with a MSSQL database using laravel homestead. It always throws the exception:
PDOException in Connector.php line 55: could not find driver.
I've seen a lot of people talking about FreeTDS and Sybase drivers, but I can't seem to figure out what I need to enable laravel/php access to MSSQL databases from a Linux Web Server running the Laravel Homestead Vagrant box.
I did lots of R&D for resolving this issue. Finally found the solution:
Laravel vagrant is using php 7. For mssql support we have to enable the relevant sybase driver for linux :
To Enable MSSQL Support for PHP 7:
First, ssh into your box vagrant ssh from the Homestead folder.
Command : vagrant ssh
Install the Sybase package for enabling the support for PDO and Mssql.
Command : sudo apt-get install php7.0-sybase
then run php -m on the ssh to make sure pdo_dblib is enabled.
All Done!!!! Cheers
The following works for php72. You may try changing the version of php in the commands.
vagrant ssh
#set the default PHP version to 7.2
php72
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version
#Ubuntu 16.04
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
#Ubuntu 18.04
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
#Ubuntu 20.04
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
sudo apt-get install unixodbc-dev
sudo pecl config-set php_ini /etc/php/7.2/fpm/php.ini
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
sudo su
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/7.2/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/7.2/mods-available/pdo_sqlsrv.ini
exit
sudo phpenmod -v 7.2 sqlsrv pdo_sqlsrv
sudo systemctl restart php7.2-fpm
# restart nginx, if needed:
sudo systemctl restart nginx.service
References:
https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#ubuntu17
https://learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15#installing-the-drivers-on-ubuntu-1604-1804-and-2004
Laravel uses PDO extension to connect to database, you could check if the extension is enabled using
var_dump(class_exists('PDO'))
Also, if you could post the specific error, it would be great.
Thanks for this. Still works as of now with:
php7.2-sybase
using DB_HOST= IP_ADDRESS\NAMED_INSTANCE
Commenting out the PORT directive in both .env and database.php

How do I install/update to Postgres 9.4?

I just installeed Postgres, but it seems to have installed 9.3 and I'd like to start with 9.4
I simply did apt-get install postgresql from a new Ubuntu 14.04.1 machine.
http://www.postgresql.org/download/linux/ubuntu/
says you can do:
apt-get install postgresql-9.4
but when I try that I get:
E: Couldn't find any package by regex 'postgresql-9.4
Okay, so I try the section below where you add the PostgreSQL Apt Repository but that can't find anything either.
Is 9.4 not in the package managers yet? Am I doing something horribly wrong?
You can add it from the instructions in the page
http://www.postgresql.org/download/linux/ubuntu/
Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
Import the repository signing key, and update the package lists
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update && sudo apt-get install postgresql-9.4
postgresql-9.4 is not available in 14.04 "Trusty". It was added in 14.10 "Utopic". It may be back ported in the future.
The directions on the PostgreSQL Ubuntu Download page are missing a command. Their wiki guide has the correct procedure. You must run apt-get update before trying to install. This will cause the system to read changes to the sources.
If you're trying to install on Ubuntu 14.04 "Trusty", you can follow these steps:
To check your version:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
1) Create new apt repo file for postgres
$ echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list
2) Import repository signing key and update packages list
$ sudo wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update
3) Install Postgres
$ sudo apt-get install postgresql-9.4
credit: http://ubuntuhandbook.org/index.php/2014/02/install-postgresql-ubuntu-14-04/
Below are steps to install PostgreSQL 9.4 on Ubuntu 14.04.
Reference taken from this Article:
First, check the version of Ubuntu:
lsb_release -sc
You need to add the latest PostgreSQL repository for the latest version, otherwise It will install PostgreSQL 9.3. This is for trusty version.
sudo add-apt-repository "deb https://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"
Update and Install PostgreSQL 9.4:
sudo apt-get update
sudo apt-get install postgresql-9.4
Default postgres super user and postgres database is created. You need to set a password for the postgres super user.
ubuntu#:~$ sudo passwd postgres
Enter new UNIX password:****
Retype new UNIX password:****
passwd: password updated successfully
If service is not started, you can start the PostgreSQL service.
sudo service postgresql start
Connect PostgreSQL server using postgres user:
ubuntu#:~$ su postgres
Password:****
Create a sample database:
createdb database_name
Connect to that database:
psql -d database_name
Follow these steps to install postgresql. Open the terminal (Ctrl + Alt + t) and then write down the following command line
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6
If postgresql installed successfully then it will return this after writing this command
psql --version
psql (PostgreSQL) 9.6.3
PostgreSQL is an open source object-relational database system. It is one of leading database server used for production servers. PostgreSQL allows us to execute stored procedures in various programming languages, like PHP, C/C++, Python, Java, Perl, Ruby and its own PL/pgSQL, which is similar to Oracleā€™s PL/SQL.
Postgres database is used the persistent store of data
Install Postgres
yum install postgres
(Note : remember the password for the postgres user ā€“ you need it later)
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql-9.6
Setting up Postgres
Launch pgAdmin.
Connect to the local server. Use localhost for the server name, postgres for the username and the password you used when you installed Postgres.
You need to be root to perform this command.Note: If you did not set password during installation (sudo apt-get install postgresql), then you can set it as follows:
ļæ¼
sudo -u postgres psql postgres
On the postgres client prompt, use the following command to set the password.
alter user postgres with password 'postgres';
Connect to PostgreSQL
After installing PostgreSQL database server, by default,, it creates a user ā€˜postgresā€™ with role ā€˜postgresā€™. It also creates a system account with same name ā€˜postgresā€™. So to connect to postgres server, log in to your system as user postgres and connect database.
$ sudo su - postgres
$ psql
Now you are logged in to PostgreSQL database server. To check login info use following command from database command prompt.
postgres-# \conninfo
To disconnect from PostgreSQL database command prompt just type below command and press enter. It will return you back to Ubuntu command prompt.
postgres-# \q

Resources