I already have postgresql installed (psql (PostgreSQL) 13.4) and the local server set-up on my windows machine (along with pgAdmin4), and already have some databases in it.
I've recently installed WSL and planning on using it instead of windows+bash going forward. Hence I'm installing postgresql 13 for WSL. I follow https://pgdash.io/blog/postgres-13-getting-started.html for the installation:
# add the repository
> sudo tee /etc/apt/sources.list.d/pgdg.list <<END
> deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main
> END
# get the signing key and import it
> wget https://www.postgresql.org/media/keys/ACCC4CF8.asc sudo apt-key add
> ACCC4CF8.asc
# fetch the metadata from the new repo
> sudo apt-get update
> sudo apt-get install -y postgresql-13
It installed postgres with psql --version = psql (PostgreSQL) 13.4 (Ubuntu 13.4-1.pgdg20.04+1)
Then I start the service with
> sudo service postgresql start
> sudo -u postgres psql
My questions are:
When I check the list of databases I have using \l, I can't see my existing postgres database that I have in my windows machine, why? and how do I connect/import it to the wsl?
How do I make the WSL database/server appears in my existing pgAdmin4 GUI? I have already a server for my windows machine (localhost, port 5432). How can I add database from the WSL server, since it has the same settings? For example, I tried creating new database via WSL psql command line CREATE DATABASE ubuntu;, and the new database appears in the WSL postgres list in terminal, but the pgAdmin GUI only shows database from my windows server. How do I sync both databases in windows and WSL and show them both in pgAdmin?
database list in windows (from pgAdmin4)
database list in WSL
Thanks for the help
Related
I want to be able to run some interactive commands inside a SQL Server Docker instance. Since I not familiar with bash and I have some PowerShell knowledge I would use PowerShell Core.
How to install PowerShell Core on top of a SQL Server docker image?
Create the following Dockerfile (example for SQL Server 2019 image, most content from here):
FROM mcr.microsoft.com/mssql/server:2019-latest AS base
# This is required since the instance uses mssql user and the following command require root or sudo
# This is used to avoid installing sudo
USER root
# Download the Microsoft repository GPG keys
RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
RUN dpkg -i packages-microsoft-prod.deb
# Update the list of products
RUN apt-get update
# Install PowerShell
RUN apt-get install -y powershell
# Revert back to default user used by SQL instance
USER mssql
To interactively work with the docker instance, explicitly use the root user (source):
docker exec -u 0 -it mssqlcontainer pwsh
PowerShell 7.0.0
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/powershell
Type 'help' to get help.
PS /> $PSVersionTable.PSVersion
Major Minor Patch PreReleaseLabel BuildLabel
----- ----- ----- --------------- ----------
7 0 0
I have created a database in MySQL using XAMPP But In Some How My XAMPP Server is Not Working Now I am trying to Get My data Back
It's in
xampp\mysql\data
folder. Or you can export the database in PHPmyadmin.
If you use Linux, you can install mysql-client and mysql-server:
sudo apt-get install mysql-client
sudo apt-get install mysql-server
and then access to phpMyAdmin with navigate to where you extract mysql. Then run this command:
php -S localhost:80
If you use windows, you can use an alternative software instead. I think Laragon is a good alternative software.
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
I will create a django app on Debian 7 with postgreSQL 9.2.
I created a droplet in digital ocean. I updated and upgraded the system.
I used the following command
sudo aptitude install postgresql postgresql-contrib
to install postgresql.
When I changed user to postgres and I wanted to create a new db user with createuser -P
I filled all the fields it wanted but it came up with this error:
createuser: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I tried same process a few times with new droplets in Ubuntu 12.04 and Debian 7.
What should I do?
I want to use Debian 7, so I prefer solutions with Debian.
I am new at this stuff so be explanatory please.
Thanks.
I figured it out with fixing locale problem and reinstall PostgreSQL
First:
http://perlgeek.de/en/article/set-up-a-clean-utf8-environment
Second:
How to thoroughly purge and reinstall postgresql on ubuntu?
Set up the locale and make a clean installation for postgreSQL.
Thanks!
i can only find psql command, but can't find any other postgres commands or tools, can
anyone tell me how to create database and connect to it using the default postgres
shipped with mac lion?
only if it doesn't work ,i dont' want to install another postgres instance.
PostgreSQL will be started by Launchd, if configured so.
Look for /System/Library/LaunchDaemons/org.postgresql.postgres.plist, this is an XML file and you will need to modify some settings there, like listen_address.
Default location for the PGDATA files is /var/pgsql, also found in the plist file above.
Cluster is owned by the _postgres user, so to access the “tools”, you should execute them via the sudo -u _postgres … prefix, like: sudo -u _postgres pg_ctl -D /var/pgsql -w start
I highly recommend creating another role with superuser permissions, as _postgres is sharing password with the Administrator account of your Lion.
You can also use the Server Admin tools for Lion to control PostgreSQL and other services:
sudo serveradmin list
# look for postgres in the output
sudo serveradmin fullstatus postgres
sudo serveradmin stop postgres
sudo serveradmin start postgres
Check the version of your PostgreSQL cluster, using: sudo -u _postgres psql -tc "select version()" and refer to the official manuals on how to create the database and setup initial access. Manual for the latest PostgreSQL version can be found here.
If you do not have the software installed, I strongly recommend the Enterprise DB package. It makes installing pretty darn easy.