In this repository, I will to learn how to use Flask and with those framework React.Js for Frontend development.
<<<<<<< HEAD
sudo apt update
sudo apt install postgresql postgresql-contrib
-
sudo systemctl status postgresql
- for check status on server -
sudo systemctl stop postgresql
- for stop server -
sudo systemctl start postgresql
- start server -
sudo systemctl restart postgresql
- restart server
Next, let’s try to login to the PostgreSQL console. First, we need to switch to postgres user:
dhani@dhani-virtual-machine:~$ sudo -i -u postgres
postgres@dhani-virtual-machine:~$
Now use the psql command to enter the console
postgres@dhani-virtual-machine:~$ psql
psql (11.5 (Ubuntu 11.5-1))
Type "help" for help.
postgres=#
To quit from the console, type:
\q
By default, the postgres user does not have a password. So, let’s create a new one.
Create or change postgres user password
To change postgres user or any other user, use the following syntax. For example:
ALTER ROLE postgres WITH PASSWORD '12345';
The command will change the postgres user password to 12345.
PgAdmin is a free, web-based administration tool for PostgreSQL database. It is a handy, rich features tool that you will love. You can use PgAdmin to create a new database, manage users, and do many other things. To install PgAdmin on Ubuntu 19.10, follow these steps.
Open Terminal and paste the following commands
sudo apt-get install curl ca-certificates gnupg
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Create a new file eoan-pgdg.list inside /etc/apt/sources.list.d directory and then paste the following line into the new file
deb http://apt.postgresql.org/pub/repos/apt/ eoan-pgdg main
Now we are ready to install PgAdmin.
sudo apt update
sudo apt install pgadmin4
After that, you should see the PgAdmin4 application icon in the Ubuntu application list.
It is important to make sure the user can connect to the PostgreSQL server from the network. There are some steps we need to take to enable the network access to the server.
sudo nano /etc/postgresql/12/main# nano pg_hba.conf
Add the following lines to the end of the file
host all all
0.0.0.0/0 md5
host all all ::0
md5
Close and save the file. And then restart PostgreSQL Service
sudo systemctl restart postgresql
We also need to edit the postgresql.conf file.
sudo nano /etc/postgresql/12/main/postgresql.conf
Find the following line
#listen_addresses = 'localhost'
And then change it to
listen_addresses = '*'
Close and save the file and restart the service
sudo systemctl restart postgresql
Done. Now try to connect to the PostgreSQL Server from the network. You should now able to connect.