RabbitMQ首次安装登陆User can only log in via localhost

RabbitMQ默认提供了一个guest/guest用户,但是从3.3.0 版本以后该账号只能localhost登陆(User can only log in via localhost),解决办法就是我们通过命令行创建一个管理员账号。


image.png

通过heip命令我们可以找到rabbitmq操作用户和权限相关的命令

Users:

   add_user                      Creates a new user in the internal database. This user will have no permissions for any virtual hosts by default.
   authenticate_user             Attempts to authenticate a user. Exits with a non-zero code if authentication fails.
   change_password               Changes the user password
   clear_password                Clears (resets) password and disables password login for a user
   clear_user_limits             Clears user connection/channel limits
   delete_user                   Removes a user from the internal database. Has no effect on users provided by external backends such as LDAP
   list_user_limits              Displays configured user limits
   list_users                    List user names and tags
   set_user_limits               Sets user limits
   set_user_tags                 Sets user tags

Access Control:

   clear_permissions             Revokes user permissions for a vhost
   clear_topic_permissions       Clears user topic permissions for a vhost or exchange
   list_permissions              Lists user permissions in a virtual host
   list_topic_permissions        Lists topic permissions in a virtual host
   list_user_permissions         Lists permissions of a user across all virtual hosts
   list_user_topic_permissions   Lists user topic permissions
   list_vhosts                   Lists virtual hosts
   set_permissions               Sets user permissions for a vhost
   set_topic_permissions         Sets user topic permissions for an exchange

通过以下命令创建一个用户admin,密码为admin@123

rabbitmqctl add_user admin admin@123

创建完成之后通过以下命令设置用户标签为administrator

rabbitmqctl set_user_tags admin administrator

给用户admin赋予权限,授予admin用户可访问虚拟主机 /,并在所有的资源上具备可配置、可写及可读的权限

rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"

这样我们就完成了一个用户的创建,通过以下命令可以看出当前的所有用户


image.png

最后一步,我们就可以用admin登陆管理界面啦


image.png

 

查看rabbitmq相关命令的方法

# 查看rabbitmq所有命令
rabbitmqctl help
# 查看rabbitmq具体一个命令的描述, 比如add_user
rabbitmqctl help add_user

你可能感兴趣的:(RabbitMQ首次安装登陆User can only log in via localhost)