Since I had only touched Mysql, I installed Postgresql using the installation method on the official website for verification.
This time, we assume a local postgres user connection without authentication.
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm dnf -qy module disable postgresql dnf install -y postgresql12-server /usr/pgsql-12/bin/postgresql-12-setup initdb systemctl enable postgresql-12 systemctl start postgresql-12
Select the one you want to install from the official website below and install it.
After installation, the postgres user has been added, so change the user.
Basically, the operation is performed by the postgres user.
su - postgres
Change to the directory where the configuration file is.
Make pg_ctl available in relative PATH.
You may add it to .bash_profile.
A file for basic settings. Change the settings as appropriate.
This time it is a verification, so leave it as the default.
A file that sets the network to connect to.
By changing from ident to trust, you can connect to the local host without authentication.
If postgresql.conf is the default, you may go to connect with ipv6, so change ipv6 as well.
- Change before
# IPv4 local connections: host all all 127.0.0.1/32 ident # IPv6 local connections: host all all ::1/128 ident
- After change
# IPv4 local connections: host all all 127.0.0.1/32 trust # IPv6 local connections: host all all ::1/128 trust
Reflection of settings
Apply the settings with the following command.
Confirm that you can log in with the following command.
psql -h localhost
Password change (optional)
After connecting, change the password of the postgres user.
alter role postgres with password 'password';
I installed it on the official website.
I forgot to change the ipv6 settings, I didn’t know the initial password of the postgres user, or I was caught unexpectedly.
And the initial password for the postgres user is still unknown.
- PostgreSQL classroom for database beginners