Install postgres on Ubuntu18 on AWS - postgresql

I need to run a shell script on my new Ubuntu machine in AWS which has the following command:
sudo apt-get install postgresql postgresql-contrib
But, due to some restrictions, I don't want to go to internet to do that. So, I downloaded the below two .debs and scp them to the box.
postgresql_12+213.pgdg18.04+1_all.deb
postgresql-contrib_12+213.pgdg18.04+1_all.deb
And , in the shell script, I replaced the above command with the below:
sudo dpkg -i postgresql_12+213.pgdg18.04+1_all.deb
sudo dpkg -i postgresql-contrib_12+213.pgdg18.04+1_all.deb
Now, while executing the script, i got the below error:
(Reading database ... 56588 files and directories currently installed.)
Preparing to unpack postgresql_12+213.pgdg18.04+1_all.deb ...
Unpacking postgresql (12+213.pgdg18.04+1) ...
dpkg: dependency problems prevent configuration of postgresql:
postgresql depends on postgresql-12; however:
Package postgresql-12 is not installed.
dpkg: error processing package postgresql (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
postgresql
Selecting previously unselected package postgresql-contrib.
(Reading database ... 56591 files and directories currently installed.)
Preparing to unpack postgresql-contrib_12+213.pgdg18.04+1_all.deb ...
Unpacking postgresql-contrib (12+213.pgdg18.04+1) ...
dpkg: dependency problems prevent configuration of postgresql-contrib:
postgresql-contrib depends on postgresql-contrib-12; however:
Package postgresql-contrib-12 is not installed.
dpkg: error processing package postgresql-contrib (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
postgresql-contrib
So, I tried to individually run the below command (just to check, as they work perfectly fine on my local ubuntu machine) which I believe goes to the internet:
sudo apt-get install postgresql postgresql-contrib
I get the below error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
postgresql-contrib is already the newest version (12+213.pgdg18.04+1).
postgresql is already the newest version (12+213.pgdg18.04+1).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
postgresql : Depends: postgresql-12 but it is not installable
postgresql-contrib : Depends: postgresql-contrib-12 but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
I am not very good with linux, but in the error above, I see it says that postgresql is already on the newest version. But when I try to run the below commands, they dont work:
postgres --version
postgres -V
locate /bin/postgres
psql --version
It seems postgres is not pre-installed on the machine. So, my issue here is I need to run the below command without internet access ( for which I downloaded the deb and tried but didnt work)
sudo apt-get install postgresql postgresql-contrib

Try updating your ubuntu and then install the packages again -
sudo apt-get update -y && sudo apt-get upgrade -y
Then install postgresql -
sudo apt-get install postgresql postgresql-contrib -y
Hope it helps.

Related

How to install postgis for postgresql 9.6

I want to install Postgres 9.X and Postgis for it.
I manage to install Postgres with version 9.6 with this command:
sudo apt-get install postgresql-9.6
But then when I type:
sudo apt get install postgis
I suddenly get postgres 10 and postgis for that version.
When I try something like on this link http://technobytz.com/install-postgis-postgresql-9-3-ubuntu.html my installation failed, I get this code in terminal:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
postgresql-9.3-postgis-2.1 : Depends: libgdal1 (>= 1.9.0) but it is not going to be installed
Depends: libgeos-c1 (>= 3.3.3) but it is not going to be installed
Depends: liblwgeom-2.1.8 (>= 2.1.6) but it is not going to be installed
Depends: libproj0 but it is not installable
Recommends: postgresql-contrib-9.3 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I am using Ubuntu 18.04
On ubuntu, you can use following commands:
sudo apt-get install postgresql-<xx>-postgis-<yy> postgresql-<xx>-postgis-<yy>-scripts
e.g
sudo apt-get install postgresql-9.6-postgis-2.4 postgresql-9.6-postgis-2.4-scripts
Just choose the proper version you need.

Error installing mongodb , broken ubuntu dependency

Trying to install mongo with below command
rahul#rahul ~ $ sudo apt-get install -y mongodb-org
Reading package lists... Done
Building dependency tree
Reading state information... Done
mongodb-org is already the newest version (3.6.2).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
mongodb-org : Depends: mongodb-org-tools but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
I had this same issue installing mongodb-org on an Ubuntu 18 box.
The issue was that a version of mongodb was already installed, and it had to be removed before I continued.
The solution was to run the following:
sudo apt remove mongodb-org
sudo apt purge mongodb-org
sudo apt autoremove
sudo apt-get install mongodb-org
More info can be found on the Mongodb website - apparently this is a frequent enough issue that they had to address it there!

How to install postgresql on Ubuntu 16.04 VM despite "unmet dependencies" to set up Ruby on Rails project

Ubuntu 16.04 on VirtualBox VM using Vagrant.
Windows 10 host.
Git Bash terminal.
Connected to vagrant up, vagrant ssh.
I have a fresh VM and have installed ruby and rails. I am trying to install postgresql to use for a Ruby on Rails project, but I get the following error:
vagrant#vagrant-ubuntu-trusty-64:~$ sudo apt-get install postgresql postgresql-contrib
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
postgresql : Depends: postgresql-9.6 but it is not going to be installed
postgresql-contrib : Depends: postgresql-contrib-9.6 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I've tried various things, and nothing seems to let me install postgres
I was facing same problem in my ubuntu 16.04
but i fixed that problem and it's very simple just follow these step and you will be able to install postgresql 10 in your system :
Add this to your sources.list:
sudo vim /etc/apt/sources.list
deb http://ftp.de.debian.org/debian/ wheezy main non-free contrib
deb-src http://ftp.de.debian.org/debian/ wheezy main non-free contrib
after that add these link to your pgdg.list file if it's not there you have to create and add link and save it.
sudo vim /etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main
then update your system
sudo apt-get update
sudo apt-get upgrade
and install that unmet dependencies :
apt-get install ssl-cert
that's it. now Install postgresql using these command
sudo apt-get install postgresql-10
#JosMac pointed out that I am running Ubuntu 14.04 instead of 16.04 as I had thought.
I was still running into similar errors, but I just ended up installing the rails-dev-box (https://github.com/rails/rails-dev-box) way which uses yakkety64, and seems to work.

I have to change my databasefrom MySQL to postgreSQL in django, but its not working

I have to change my databasefrom MySQL to postgreSQL in django. But postgreSQL is not installing .
Error while installing postgreSQL using commands-
sudo apt-get update && sudo apt-get upgrade
sudo apt-get purge postgresql*
sudo apt-get -f install
sudo apt-get install postgresql
At terminal-
(jango)dc#dc-comp-4:~/website$ sudo apt-get install postgresql
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
postgresql : Depends: postgresql-9.3 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
but its not working.how can i do this.and what changes i have to made. Plz help

Cannot reinstall postgresql - apt-get dependency errors

I previously could install postgresql but then I uninstalled and installed it again, now if I try:
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
This will appear:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
postgresql : Depends: postgresql-9.4 but it is not going to be installed
postgresql-contrib : Depends: postgresql-contrib-9.4 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
What's wrong here?
I want to remodel starting from scratch. So what I did before:
sudo apt-get --purge remove postgresql
sudo rm -rf /var/lib/postgresql/
sudo rm -rf /var/log/postgresql/
sudo rm -rf /etc/postgresql/
You may have a broken database. Try: sudo apt-get --fix-broken
Alternatively, it may be that there are files left behind that are conflicting with version 9.4 of postgresql. If you can, install the version of postgresql you had before, then, using dpkg-query -L <package_name>, you can see what files were installed and what you may have left behind.
run the following.
sudo apt install aptitude && sudo aptitude install postgresql postgresql-contrib