加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

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

发布时间:2020-12-12 08:56:39 所属栏目:MsSql教程 来源:网络整理
导读:首先我运行命令: sudo su _postgres 然后我运行命令: create role mixeddrinks with createdb login password 'password1' 但它回来了: -bash: create: command not found 我不太熟悉终端和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';

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读