创建角色和数据库PostgreSQL不起作用

首先我运行命令:
sudo su _postgres

然后我运行命令:

create role mixeddrinks with createdb login password 'password1'

但它回来了:

-bash: create: command not found

我不太熟悉终端和Postgresql,所以我不知道我做错了我正在尝试创建一个角色和一个数据库.

解决方法

First I run the command sudo su _postgres,then I run the command create role mixeddrinks with createdb login password 'password1'

你正在混合shell命令和psql命令行.

如果要使用sql,则需要使用psql命令. sudo su _postgres是一种低效的方法获取unix命令shell作为_postgres用户.它不给你一个sql shell.您可以从unix命令shell运行像psql,createuser等unix命令.你可以告诉你是在命令shell,因为提示如下所示:

postgres$

如果你想要一个sql shell,所以你可以运行像CREATE USER这样的命令,你需要运行psql.如果你想要一个超级用户sql shell,那就像:

sudo -u _postgres psql

这将给你一个提示

postgres=#

您可以在其中运行sql命令.请记住,sql命令以分号结尾.

postgres=# create role mixeddrinks with createdb login password 'password1';

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...