[英]psql: FATAL: role “vagrant” does not exist
I have been trying to set up vagrant but I am getting this error. 我一直试图设置流浪汉,但我收到了这个错误。 I will list out my installation method.
我将列出我的安装方法。 Please suggest changes where you feel they are needed.
请在您认为需要的地方建议更改。
-Installed virtual box - 安装虚拟盒子
sudo apt-get install virtual box
-Downloaded .deb package from vagrant website -ranown网站上的.downloaded .deb包
-Installed it using - 使用安装它
sudo dpkg -i (package_name)
-then I selected the vagrant folder in the fullstack folder and 然后我选择了fullstack文件夹中的vagrant文件夹
vagrant up
vagrant ssh
then I did : 然后我做了:
vagrant@vagrant-ubuntu-trusty-32: cd /vagrant/forum vagrant@vagrant-ubuntu-trusty-32:/vagrant/forum$ sudo apt-get install postgresql-client-common vagrant@vagrant-ubuntu-trusty-32:/vagrant/forum$ sudo apt-get install postgres-xc-client
Then finally: 最后:
vagrant@vagrant-ubuntu-trusty-32:/vagrant/forum$ psql psql: FATAL: role "vagrant" does not exist
You need to change to the postgres
user and give vagrant superuser access. 您需要更改为
postgres
用户并授予vagrant超级用户访问权限。
sudo su - postgres
createuser vagrant -s
exit # exit from postgres user back into vagrant
You can do everything with with vagrant now. 你现在可以和流浪者一起做。
This is happening because there is no role specified in postgres. 发生这种情况是因为postgres中没有指定角色。 When there is no role specified, it tries to use the username of the account as the default role and hence your error.
如果没有指定角色,它会尝试使用帐户的用户名作为默认角色,从而导致您的错误。 So, now, you could either create a role in postgres for the vagrant user or just use the postgres user itself.
所以,现在,你可以为流浪汉用户创建postgres角色,或者只使用postgres用户本身。 So, first, login with the postgres user:
所以,首先,使用postgres用户登录:
psql -U postgres
then, create a role for the user vagrant 然后,为用户流浪者创建一个角色
CREATE ROLE vagrant LOGIN;
In case, if you want it with a password, use: 如果您想要密码,请使用:
CREATE USER vagrant WITH PASSWORD 'password';
or 要么
CREATE ROLE vagrant WITH LOGIN PASSWORD 'password';
CREATE USER is the same as CREATE ROLE with the exception that USER implies LOGIN. CREATE USER与CREATE ROLE相同,但USER表示LOGIN。
1)First exit the vagrant prompt 1)首先退出流浪汉提示
exit
出口
2) Halt the vagrant instance 2)停止流浪者实例
vagrant halt
流浪汉停止
3)Destroy the vagrant instance 3)消灭流浪者实例
vagrant destroy
流浪汉毁灭
4)Create a new instance 4)创建一个新实例
vagrant up
流浪汉
This might solve it. 这可能会解决它。 It atleast did for me.(Tried it)
它至少对我有用。(尝试过)
You are trying to connect to postgresql using vagrant user. 您正在尝试使用vagrant用户连接到postgresql。 In this case, postgresql y looking for the corresponding vagrant role (if not specified, the default role for a user is it's username).
在这种情况下,postgresql y寻找相应的vagrant角色(如果未指定,则用户的默认角色是它的用户名)。 However, looks like there is no such role created.
但是,看起来没有创建这样的角色。
You can create the role, or try for example a login using the postgres user: 您可以创建角色,或尝试使用postgres用户登录:
vagrant@vagrant-ubuntu-trusty-32:/vagrant/forum$ psql -U postgres
You can also specify the databasename you want to connect to: 您还可以指定要连接的数据库名称:
vagrant@vagrant-ubuntu-trusty-32:/vagrant/forum$ psql -U postgres -d DATABASENAME
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.