[英]PostgreSQL error: could not connect to database template1: could not connect to server:
I'm running into the following error after uninstalling and installing several times I just can't seem to get postgresql working.卸载和安装几次后,我遇到了以下错误,我似乎无法让 postgresql 工作。 I am trying to setup the coding environment for ruby on rails 6 on windows 10. I have followed the following articles and have made it all the way to creating a user where i get the following errors.
我正在尝试在 windows 10 上的导轨 6 上为 ruby 设置编码环境。我已按照以下文章进行操作,并一直致力于创建一个我得到以下错误的用户。
links to how i got here指向我如何到达这里的链接
https://github.com/serivas/wsl2_rails_setup https://github.com/serivas/wsl2_rails_setup
https://gorails.com/setup/windows/10#ruby-rbenv https://gorails.com/setup/windows/10#ruby-rbenv
https://www.postgresql.org/download/linux/ubuntu/ https://www.postgresql.org/download/linux/ubuntu/
Error I'm getting when i type我输入时遇到的错误
sudo -u postgres createuser abc -s
Error Message;错误信息;
createuser: error: could not connect to database template1: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Thanks in advance!提前致谢!
Here's how I solved my problem for anyone that might be having similar issues.这是我为可能遇到类似问题的任何人解决问题的方法。
Make sure that your windows 10 is updated to be able to run WSL2确保您的 windows 10 已更新以能够运行 WSL2
First follow the link below to get Ruby and Rails installed.首先按照下面的链接安装 Ruby 和 Rails。
https://gorails.com/setup/windows/10 https://gorails.com/setup/windows/10
Setup PostgreSQL from the link above,从上面的链接设置 PostgreSQL,
the link below also help me setup PostgreSQL;下面的链接也帮助我设置 PostgreSQL;
https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-database https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-database
If your having trouble logging into Postgres make sure that you create a user in Postgres that allows the user to be able to CREATEDB.如果您在登录 Postgres 时遇到问题,请确保您在 Postgres 中创建一个允许该用户能够 CREATEDB 的用户。 So if your user is JohnDoe make sure that you give permission for JohnDoe to create database.
因此,如果您的用户是 JohnDoe,请确保您授予 JohnDoe 创建数据库的权限。
Links to help you out with granting permission.帮助您授予权限的链接。
Make sure that you are starting your postgresql server.确保您正在启动 postgresql 服务器。
sudo service postgresql start
And to Stop并停止
sudo service postgresql stop
After User has rights to create the database, then you can go ahead and type in用户有权创建数据库后,您可以提前 go 并输入
rake db:create
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.