ВНИМАНИЕ ! ! ! Если мы работаем от root пользователя, то мы не сможем подключиться к СУБД PostgreSQL. Мы получим ошибку вида.
psql: ошибка: подключиться к серверу через сокет "/var/run/postgresql/.s.PGSQL.5432" не удалось: ВАЖНО: роль "root" не существует
Нам нужно изменить пользователя в терминале Debian. Меняем root на кого? После установки PostgreSQL в систему, вместе с ней устанавливается и новый пользователь. Его зовут postgres. По умолчанию он не имеет пароля для входа.
Команда смены пользователя root на postgres в Debian:
su - postgres
Обратите внимание на терминальную оболочку. В ней изменилась запись пользователя:
Теперь мы сможем работать с утилитой psql. Подключаемся к СУБД при помощи утилиты:
psql
Нам возвращаются версии ПО.
Обратите внимание на самую низкую запись:
postgres=#
Она говорит о том, что теперь мы находимся в самом интерфейсе СУБД PostgreSQL. Ещё она говорит о том, что мы сразу подключились к базе данных, которая тоже называется postgres. Есть пользователь postgres, а есть база данных postgres. Оба они устанавливаются по умолчанию. Не путайте! С этого момент мы можем начать вводить команды.
Во внутреннем интерфейсе вводим мета-команду:
du
или
dg
Вы получите список доступных пользователей в системе PostgreSQL. Вам будут известны их атрибуты ролей и список групп ролей, членами которых они являются.
В нашем случае есть только один пользователь. Это тот самый postgres, от имени которого мы подключились к СУБД.
Справка
Метакоманды — это всё, что вводится в psql не взятое в кавычки и начинающееся с обратной косой черты, является метакомандой psql и обрабатывается самим psql. Эти команды делают psql полезным для задач администрирования и разработки скриптов.
Формат команды psql следующий: обратная косая черта, сразу за ней команда, затем аргументы. Аргументы отделяются от команды и друг от друга любым количеством пробелов.
Чтобы выйти нужно использовать клавишу с буквой Q.
Информационные ссылки
Список команд программы PSQL — https://postgrespro.ru/docs/postgresql/14/app-psql
Официальный сайт PostgreSQL — https://www.postgresql.org
Графический веб-интерфейс для управления СУБД PostgreSQL — https://www.pgadmin.org
I check
test: [ "CMD", "pg_isready", "-q", "-d", "kong", "-U", "kong" ]
Don`t have error
But have another error
docker-compose up 0.2s
[+] Running 4/3
- Network docker-compose-healthcheck_default Created 0.0s
- Container kong-postgres Created 2.8s
- Container kong-migration Created 0.1s
- Container kong Created 0.1s
Attaching to kong, kong-migration, kong-postgres
kong-postgres | ********************************************************************************
kong-postgres | WARNING: POSTGRES_HOST_AUTH_METHOD has been set to "trust". This will allow
kong-postgres | anyone with access to the Postgres port to access your database without
kong-postgres | a password, even if POSTGRES_PASSWORD is set. See PostgreSQL
kong-postgres | documentation about "trust":
kong-postgres | https://www.postgresql.org/docs/current/auth-trust.html
kong-postgres | In Docker's default configuration, this is effectively any other
kong-postgres | container on the same system.
kong-postgres |
kong-postgres | It is not recommended to use POSTGRES_HOST_AUTH_METHOD=trust. Replace
kong-postgres | it with "-e POSTGRES_PASSWORD=password" instead to set a password in
kong-postgres | "docker run".
kong-postgres | ********************************************************************************
kong-postgres | The files belonging to this database system will be owned by user "postgres".
kong-postgres | This user must also own the server process.
kong-postgres |
kong-postgres | The database cluster will be initialized with locale "en_US.utf8".
kong-postgres | The default database encoding has accordingly been set to "UTF8".
kong-postgres | The default text search configuration will be set to "english".
kong-postgres |
kong-postgres | Data page checksums are disabled.
kong-postgres |
kong-postgres | fixing permissions on existing directory /var/lib/postgresql/data ... ok
kong-postgres | creating subdirectories ... ok
kong-postgres | selecting default max_connections ... 100
kong-postgres | selecting default shared_buffers ... 128MB
kong-postgres | selecting default timezone ... Etc/UTC
kong-postgres | selecting dynamic shared memory implementation ... posix
kong-postgres | creating configuration files ... ok
kong-postgres | creating template1 database in /var/lib/postgresql/data/base/1 ... ok
kong-postgres | initializing pg_authid ... ok
kong-postgres | setting password ... ok
kong-postgres | initializing dependencies ... ok
kong-postgres | creating system views ... ok
kong-postgres | loading system objects' descriptions ... ok
kong-postgres | creating collations ... ok
kong-postgres | creating conversions ... ok
kong-postgres | creating dictionaries ... ok
kong-postgres | setting privileges on built-in objects ... ok
kong-postgres | creating information schema ... ok
kong-postgres | loading PL/pgSQL server-side language ... ok
kong-postgres | vacuuming database template1 ... ok
kong-postgres | copying template1 to template0 ... ok
kong-postgres | copying template1 to postgres ... ok
kong-postgres | syncing data to disk ... ok
kong-postgres |
kong-postgres | Success. You can now start the database server using:
kong-postgres |
kong-postgres | pg_ctl -D /var/lib/postgresql/data -l logfile start
kong-postgres |
kong-postgres |
kong-postgres | WARNING: enabling "trust" authentication for local connections
kong-postgres | You can change this by editing pg_hba.conf or using the option -A, or
kong-postgres | --auth-local and --auth-host, the next time you run initdb.
kong-postgres | waiting for server to start....LOG: database system was shut down at 2022-02-15 04:04:37 UTC
kong-postgres | LOG: MultiXact member wraparound protections are now enabled
kong-postgres | LOG: autovacuum launcher started
kong-postgres | LOG: database system is ready to accept connections
kong-postgres | done
kong-postgres | server started
kong-postgres | CREATE DATABASE
kong-postgres |
kong-postgres |
kong-postgres | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
kong-postgres |
kong-postgres | waiting for server to shut down....LOG: received fast shutdown request
kong-postgres | LOG: aborting any active transactions
kong-postgres | LOG: autovacuum launcher shutting down
kong-postgres | LOG: shutting down
kong-postgres | LOG: database system is shut down
kong-postgres | done
kong-postgres | server stopped
kong-postgres |
kong-postgres | PostgreSQL init process complete; ready for start up.
kong-postgres |
kong-postgres | LOG: database system was shut down at 2022-02-15 04:04:38 UTC
kong-postgres | LOG: MultiXact member wraparound protections are now enabled
kong-postgres | LOG: autovacuum launcher started
kong-postgres | LOG: database system is ready to accept connections
kong-migration | Bootstrapping database...
kong-migration | migrating core on database 'kong'...
kong-migration | core migrated up to: 000_base (executed)
kong-migration | core migrated up to: 003_100_to_110 (executed)
kong-migration | core migrated up to: 004_110_to_120 (executed)
kong-migration | core migrated up to: 005_120_to_130 (executed)
kong-migration | core migrated up to: 006_130_to_140 (executed)
kong-migration | core migrated up to: 007_140_to_150 (executed)
kong-migration | core migrated up to: 008_150_to_200 (executed)
kong-migration | core migrated up to: 009_200_to_210 (executed)
kong-migration | core migrated up to: 010_210_to_211 (executed)
kong-migration | core migrated up to: 011_212_to_213 (executed)
kong-migration | core migrated up to: 012_213_to_220 (executed)
kong-migration | core migrated up to: 013_220_to_230 (executed)
kong-migration | core migrated up to: 014_230_to_270 (executed)
kong-migration | migrating acl on database 'kong'...
kong-migration | acl migrated up to: 000_base_acl (executed)
kong-migration | acl migrated up to: 002_130_to_140 (executed)
kong-migration | acl migrated up to: 003_200_to_210 (executed)
kong-migration | acl migrated up to: 004_212_to_213 (executed)
kong-migration | migrating acme on database 'kong'...
kong-migration | acme migrated up to: 000_base_acme (executed)
kong-migration | migrating basic-auth on database 'kong'...
kong | 2022/02/15 04:04:50 [warn] 1#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/kong/nginx.conf:6
kong | nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/kong/nginx.conf:6
kong | 2022/02/15 04:04:50 [error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/cmd/utils/migrations.lua:20: New migrations available; run 'kong migrations up' to proceed
kong | stack traceback:
kong | [C]: in function 'error'
kong | /usr/local/share/lua/5.1/kong/cmd/utils/migrations.lua:20: in function 'check_state'
kong | /usr/local/share/lua/5.1/kong/init.lua:506: in function 'init'
kong | init_by_lua:3: in main chunk
kong | nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/cmd/utils/migrations.lua:20: New migrations available; run 'kong migrations up'
to proceed
kong | stack traceback:
kong | [C]: in function 'error'
kong | /usr/local/share/lua/5.1/kong/cmd/utils/migrations.lua:20: in function 'check_state'
kong | /usr/local/share/lua/5.1/kong/init.lua:506: in function 'init'
kong | init_by_lua:3: in main chunk
kong-migration | basic-auth migrated up to: 000_base_basic_auth (executed)
kong-migration | basic-auth migrated up to: 002_130_to_140 (executed)
kong-migration | basic-auth migrated up to: 003_200_to_210 (executed)
kong-migration | migrating bot-detection on database 'kong'...
kong-migration | bot-detection migrated up to: 001_200_to_210 (executed)
kong-migration | migrating hmac-auth on database 'kong'...
kong-migration | hmac-auth migrated up to: 000_base_hmac_auth (executed)
kong-migration | hmac-auth migrated up to: 002_130_to_140 (executed)
kong-migration | hmac-auth migrated up to: 003_200_to_210 (executed)
kong-migration | migrating ip-restriction on database 'kong'...
kong-migration | ip-restriction migrated up to: 001_200_to_210 (executed)
kong-migration | migrating jwt on database 'kong'...
kong-migration | jwt migrated up to: 000_base_jwt (executed)
kong-migration | jwt migrated up to: 002_130_to_140 (executed)
kong-migration | jwt migrated up to: 003_200_to_210 (executed)
kong-migration | migrating key-auth on database 'kong'...
kong-migration | key-auth migrated up to: 000_base_key_auth (executed)
kong-migration | key-auth migrated up to: 002_130_to_140 (executed)
kong-migration | key-auth migrated up to: 003_200_to_210 (executed)
kong-migration | migrating oauth2 on database 'kong'...
kong-migration | oauth2 migrated up to: 000_base_oauth2 (executed)
kong-migration | oauth2 migrated up to: 003_130_to_140 (executed)
kong-migration | oauth2 migrated up to: 004_200_to_210 (executed)
kong-migration | oauth2 migrated up to: 005_210_to_211 (executed)
kong-migration | migrating rate-limiting on database 'kong'...
kong-migration | rate-limiting migrated up to: 000_base_rate_limiting (executed)
kong-migration | rate-limiting migrated up to: 003_10_to_112 (executed)
kong-migration | rate-limiting migrated up to: 004_200_to_210 (executed)
kong-migration | migrating response-ratelimiting on database 'kong'...
kong-migration | response-ratelimiting migrated up to: 000_base_response_rate_limiting (executed)
kong-migration | migrating session on database 'kong'...
kong-migration | session migrated up to: 000_base_session (executed)
kong-migration | session migrated up to: 001_add_ttl_index (executed)
kong-migration | 42 migrations processed
kong-migration | 42 executed
kong-migration | Database is up-to-date
kong exited with code 1
kong-migration exited with code 0
kong | 2022/02/15 04:04:52 [warn] 1#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/kong/nginx.conf:6
kong | nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/kong/nginx.conf:6
kong | 2022/02/15 04:04:52 [notice] 1#0: using the "epoll" event method
kong | 2022/02/15 04:04:52 [notice] 1#0: openresty/1.19.9.1
kong | 2022/02/15 04:04:52 [notice] 1#0: built by gcc 10.3.1 20210424 (Alpine 10.3.1_git20210424)
kong | 2022/02/15 04:04:52 [notice] 1#0: OS: Linux 5.10.60.1-microsoft-standard-WSL2
kong | 2022/02/15 04:04:52 [notice] 1#0: getrlimit(RLIMIT_NOFILE): 1048576:1048576
kong | 2022/02/15 04:04:52 [notice] 1#0: start worker processes
kong | 2022/02/15 04:04:52 [notice] 1#0: start worker process 1098
kong | 2022/02/15 04:04:52 [notice] 1#0: start worker process 1099
kong | 2022/02/15 04:04:52 [notice] 1#0: start worker process 1100
kong | 2022/02/15 04:04:52 [notice] 1#0: start worker process 1101
kong | 2022/02/15 04:04:52 [notice] 1#0: start worker process 1102
kong | 2022/02/15 04:04:52 [notice] 1#0: start worker process 1103
kong | 2022/02/15 04:04:52 [notice] 1#0: start worker process 1104
kong | 2022/02/15 04:04:52 [notice] 1#0: start worker process 1105
kong | 2022/02/15 04:04:52 [notice] 1099#0: *3 [kong] init.lua:311 only worker #0 can manage, context: init_worker_by_lua*
kong | 2022/02/15 04:04:52 [notice] 1101#0: *4 [kong] init.lua:311 only worker #0 can manage, context: init_worker_by_lua*
kong | 2022/02/15 04:04:52 [notice] 1098#0: *1 [lua] warmup.lua:92: single_dao(): Preloading 'services' into the core_cache..., context: init_worker_by
context: init_worker_by_lua*
kong | 2022/02/15 04:04:52 [notice] 1103#0: *5 [kong] init.lua:311 only worker #0 can manage, context: init_worker_by_lua*
kong | 2022/02/15 04:04:52 [notice] 1105#0: *8 [kong] init.lua:311 only worker #0 can manage, context: init_worker_by_lua*
kong | 2022/02/15 04:04:52 [notice] 1100#0: *2 [kong] init.lua:311 only worker #0 can manage, context: init_worker_by_lua*
kong | 2022/02/15 04:04:52 [notice] 1098#0: *1 [lua] warmup.lua:129: single_dao(): finished preloading 'services' into the core_cache (in 0ms), contextcache (in 0ms), context: init_worker_by_lua*
kong | 2022/02/15 04:04:52 [notice] 1102#0: *7 [kong] init.lua:311 only worker #0 can manage, context: init_worker_by_lua*
kong | 2022/02/15 04:04:52 [notice] 1104#0: *6 [kong] init.lua:311 only worker #0 can manage, context: init_worker_by_lua*
kong | 2022/02/15 04:04:57 [crit] 1105#0: *15 [lua] balancers.lua:240: create_balancers(): failed loading initial list of upstreams: failed to get fromams: failed to get from node cache: could not acquire callback lock: timeout, context: ngx.timer
kong | 2022/02/15 04:04:57 [crit] 1103#0: *12 [lua] balancers.lua:240: create_balancers(): failed loading initial list of upstreams: failed to get fromams: failed to get from node cache: could not acquire callback lock: timeout, context: ngx.timer
kong | 2022/02/15 04:04:57 [crit] 1100#0: *14 [lua] balancers.lua:240: create_balancers(): failed loading initial list of upstreams: failed to get fromams: failed to get from node cache: could not acquire callback lock: timeout, context: ngx.timer
kong | 2022/02/15 04:04:57 [crit] 1102#0: *16 [lua] balancers.lua:240: create_balancers(): failed loading initial list of upstreams: failed to get fromams: failed to get from node cache: could not acquire callback lock: timeout, context: ngx.timer
kong | 2022/02/15 04:04:57 [crit] 1101#0: *13 [lua] balancers.lua:240: create_balancers(): failed loading initial list of upstreams: failed to get fromams: failed to get from node cache: could not acquire callback lock: timeout, context: ngx.timer
kong | 2022/02/15 04:04:57 [crit] 1098#0: *17 [lua] balancers.lua:240: create_balancers(): failed loading initial list of upstreams: failed to get fromams: failed to get from node cache: could not acquire callback lock: timeout, context: ngx.timer
kong | 2022/02/15 04:04:57 [crit] 1104#0: *18 [lua] balancers.lua:240: create_balancers(): failed loading initial list of upstreams: failed to get fromams: failed to get from node cache: could not acquire callback lock: timeout, context: ngx.timer
My first attempt to install a module. In the process I’ve got an error:
socket.error: [Errno 98] Address already in use in OpenERP
Tried to solve like this:
ps aux | grep openerp
sudo kill -9 procees id
sudo /etc/init.d/openerp-server restart (=> this doesn't work)
Now I get an other error OperationalError: FATAL: role «root» does not exist and the website is down.
Can someone help me out?
6Ответы
500 internal server error (Linux)
OperationalError: FATAL: role «root» does not exist
You find this error in file : /var/log/postgrsql/postgrsql-10-main.log (on linux system)
The solution may be :
1- Open Terminal and enter => sudo su postgres
2- Enter password for postgres System user (if it is necessary)
3- createuser root -s
4- psql template1
5- alter role root with password ‘yourpassword’;
6- q
7- exit
8- service odoo restart
Now try again to localhost:8069
Dennis,
You have to create user role for postgres.
sudo -u postgres createuser -s username
sudo su postgres psql alter user username with password 'password'; q exit
me pueden ayudarme para darle permiso para ingresar odoo
Thank you so much, it worked for me
Thanks so much, it work, this fix my problem.
Thanks so much, it works for me too, I solved my problem using this command.
I’m setting up my PostgreSQL 9.1 in windows.
I can’t do anything with PostgreSQL: can’t createdb, can’t createuser; all operations return the error message
Fatal: role root does not exist
root is my account name, which I created while installing Postgresql
But I am able to connect using:
username : postgres
How can I connect to postgres using role root
?
There is a solution mentioned for linux platforms using su command here but not able to figure out solution for windows7
Thanks in Advance
asked Feb 2, 2015 at 11:26
1
If you want to login to Postgres using the username root
you need to first create such a user.
You first need to login as the Postgres super user. This is typically postgres
(and is specified during installation):
psql -U postgres <user-name>
Then you can create roles and databases:
psql (9.4.0)
Type "help" for help.
postgres=# create user root with password 'verysecret';
CREATE ROLE
postgres=# \q
c:\
c:\>psql -U root postgres
psql (9.4.0)
Type "help" for help.
postgres=>
Logged in as the superuser you can also grant the root
user the necessary privileges.
All parameters for psql
are documented in the manual.
Creating users and databases is also documented in the manual:
- connecting to the database
- create user
- create database
bathyscapher
1,6371 gold badge13 silver badges19 bronze badges
answered Feb 2, 2015 at 11:35
5
In some cases, when you install postgres the initial DB is not created.
You need to execute initdb.
answered Aug 28, 2018 at 20:19
NatachaNatacha
1,13116 silver badges23 bronze badges
Same issue appeared while restoring DB/table on postgres docker container .
-
. When you connect to Postgres DB(psql shell) from inside the docker container, the default user would be a «root» (unless you specify
psql -U "some-user-name"
)
[Manjunath-MacBook-Air:$ sudo docker exec -it a2ff6075344e bash
bash-5.0# psql -U postgres postgres < testdb_pg_dump
-
So, the issue gets resolved, by logging to psql shell with appropriate username
Here , -U postgres
specifies that user connecting to DB is «postgres»
answered Aug 6, 2020 at 3:46
Manju NManju N
8969 silver badges14 bronze badges
The error «FATAL: role «root» does not exist» occurs when trying to run a Postgresql database through Docker Compose and the user tries to connect as the «root» user which is not present in the Postgresql setup. The root cause of this issue is the lack of an existing role with the name «root» in the Postgresql setup. This can lead to difficulty connecting to the database and running necessary queries and operations. To resolve this issue, there are several methods that can be tried.
Method 1: Create a new role with the name «root»
To fix the «FATAL: role ‘root’ does not exist» error when using PostgreSQL with Docker Compose, you can create a new role with the name «root» by following these steps:
- Open the PostgreSQL command line interface by running the following command:
docker-compose exec db psql -U postgres
- Once you’re in the command line interface, run the following SQL command to create a new role with the name «root»:
CREATE ROLE root WITH LOGIN PASSWORD 'password';
- Grant the new role superuser privileges by running the following SQL command:
ALTER ROLE root SUPERUSER;
- Exit the command line interface by running the following command:
- Restart the Docker Compose services by running the following command:
After completing these steps, the «FATAL: role ‘root’ does not exist» error should be resolved and you should be able to connect to your PostgreSQL database using the «root» role.
Method 2: Connect with a different role
To fix the «FATAL: role «root» does not exist» error in Postgresql with Docker Compose, you can connect with a different role. Here are the steps:
- Open your Docker Compose file and add the following environment variables to the Postgresql service:
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: example
POSTGRES_DB: example_db
- Save the file and run the following command to start the containers:
- Once the containers are running, connect to the Postgresql service with the following command:
docker-compose exec postgres psql -U postgres
-
You will be prompted for a password. Enter the password you set in the environment variable (in this example, «example»).
-
Once you are connected to the Postgresql service, create a new role with the following command:
CREATE ROLE root WITH LOGIN PASSWORD 'root';
- Grant the new role superuser privileges with the following command:
ALTER ROLE root SUPERUSER;
- Exit the Postgresql service with the following command:
- Stop and remove the containers with the following command:
- Start the containers again with the following command:
- Your Postgresql service should now be running without any errors.
That’s it! By connecting with a different role and creating a new superuser role, you can fix the «FATAL: role «root» does not exist» error in Postgresql with Docker Compose.
Method 3: Specify a different username in the connection command
To fix the «FATAL: role ‘root’ does not exist» error when using Postgresql with Docker Compose, you can specify a different username in the connection command. Here are the steps to do it:
- Open your docker-compose.yml file and add the POSTGRES_USER environment variable with your desired username. For example:
services:
db:
image: postgres
environment:
POSTGRES_USER: myusername
POSTGRES_PASSWORD: mypassword
- In your application code, replace the default «root» username with the one you specified in the docker-compose.yml file. Here’s an example using Node.js and the
pg
library:
const { Pool } = require('pg');
const pool = new Pool({
user: 'myusername',
host: 'localhost',
database: 'mydatabase',
password: 'mypassword',
port: 5432,
});
pool.query('SELECT NOW()', (err, res) => {
console.log(err, res);
pool.end();
});
- Start your Docker Compose services with
docker-compose up
.
That’s it! Now your application should be able to connect to the Postgresql database using the specified username.
I started a postgres docker container using
sudo docker run --name some-postgres -d postgres
and then attempted to connect to it using
sudo docker run -it --rm --link some-postgres:postgres postgres psql -h postgres
which gives the error psql: FATAL: role "root" does not exist
These commands are exactly the same as the ones listed on the docker hub page Only run as root and without -e POSTGRES_PASSWORD=mysecretpassword
Have I done something wrong here? What could be causing this?
asked Jun 19, 2018 at 13:56
$ docker run --rm --name some-postgres -d postgres
cb2ddbb0f4f715077ebc1bfc2dc7151e5a6d07cd374c28be1db6d6ad77b9b16a
$ docker run -it --rm --link some-postgres:postgres postgres psql -h postgres -U postgres
psql (10.4 (Debian 10.4-2.pgdg90+1))
Type "help" for help.
postgres=#
You forgot the -U postgres
answered Jun 25, 2018 at 22:28
You must log in to answer this question.
Not the answer you’re looking for? Browse other questions tagged
.
Not the answer you’re looking for? Browse other questions tagged
.
Обновлено
Вопрос:
Я создаю команду bash в PHP скрипт. Встроенная команда такова:
su postgres -c "for tbl in `psql -qAt -c \"select tablename from pg_tables where schemaname = 'public';\" demodoo` ;do psql -c \"alter table $tbl owner to postgres\" demodoo ;done "
Когда я пытаюсь запустить эту команду в оболочке, я получаю эту ошибку:
psql: FATAL: role "root" does not exist
Почему это происходит, тогда как я выполняю команду под пользователем postgres?
Спасибо
Cheers,
ИЗМЕНИТЬ
Я меняю команду на
sudo -u postgres for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" demodoo` ;do psql -c "alter table $tbl owner to postgres" demodoo ;done
но теперь я получаю еще одну ошибку, которая не может понять происхождение:
-bash: syntax error near unexpected token `do'
Ответ №1
попробовать:
sudo -u postgres psql
>
CREATE USER root WITH SUPERUSER;
Ответ №2
Я хочу, чтобы он работал, сохраняя содержимое команды
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" demodoo` ;do psql -c "alter table $tbl owner to postgres" demodoo ;done
в файле myfile.sh
, затем вызовите файл следующим образом:
sudo -u postgres /bin/bash myfile.sh
Спасибо за помощь