PostgreSQL Kullanıcı Reset | Veritabanı Taşıma

Mobil uygulama, web uygulaması, oyun geliştirme, ağ yönetimi ve diğer konular ile ilgili bilgileri burada bulabilirsiniz
Cevapla
Kullanıcı avatarı
melihcelenk
Site Admin
Mesajlar: 217
Kayıt: 05 Eki 2021, 03:23

PostgreSQL Kullanıcı Reset | Veritabanı Taşıma

Mesaj gönderen melihcelenk »

# Step 1: Resetting the Password or Creating a New User

Find out the name of your PostgreSQL Docker container:
docker ps
Access the PostgreSQL container's bash shell:
docker exec -it <container_name> bash
Access the PostgreSQL command line:
psql -U postgres
If you need to create a new user and database, run:
CREATE USER <username> WITH PASSWORD '<password>';
CREATE DATABASE <database_name> WITH OWNER <username>;
Grant privileges to the user (if necessary):
GRANT ALL PRIVILEGES ON DATABASE <database_name> TO <username>;
Exit the PostgreSQL command line:
\q
___________________________________________________________________________

# Step 2: Importing the Remote Database

Option 1: Install the Matching PostgreSQL Client Version

Add the PostgreSQL apt repository
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Update package lists
sudo apt-get update
Install the matching client version
sudo apt-get install postgresql-client-14
____________________________________________________________________________


Here's how you can copy the dump.sql file from your host machine into the PostgreSQL container:
docker cp dump.sql <container_name>:/tmp/dump.sql
After you've copied the file into the container, you can then use the psql command inside the container to import the SQL dump:
docker exec -it <container_name> psql -U <username> -d <database_name> -a -f /tmp/dump.sql

___________________________________________________________________________
Cevapla