无法混合ecto.create,角色'postgres'不存在

qua*_*ato 14 postgresql elixir ecto phoenix-framework

我尝试创建一个名为postgres的用户.我重新安装了postgres brew.我能用它来运行它

postgres -D /usr/local/var/postgres

当我跑步时mix ecto.create,我仍然得到错误:

~/code/blog_phoenix:.mix ecto.create
** (Mix) The database for BlogPhoenix.Repo couldn't be created, reason given: psql: FATAL:  role "postgres" does not exist.
~/code/blog_phoenix:.
Run Code Online (Sandbox Code Playgroud)

jos*_*mrb 16

看起来您的数据库安装缺少该角色postgres.

您应该尝试使用默认凭据进行连接,然后执行SQL语句以创建角色及其默认数据库.

在控制台运行中:

$ psql
Run Code Online (Sandbox Code Playgroud)

然后

CREATE USER postgres SUPERUSER;
CREATE DATABASE postgres WITH OWNER postgres;
Run Code Online (Sandbox Code Playgroud)