怎么设置tomcat管理员的用户名和密码

时间:2021-08-28 16:54:22

TomcatXML.原来的tomcat-user.xml是:

====================================

<?xml version="1.0" encoding="utf-8" ? >
<tomcat-users >
     <role rolename="tomcat" / > 
      <role rolename="role1" / > 
      <user username="both" password="tomcat" roles="tomcat,role1" / > 
      <user username="tomcat" password="tomcat" roles="tomcat" / > 
      <user username="role1" password="tomcat" roles="role1" / >
</tomcat-users >


====================================
这里role 只有tomcat role1权限的用户,而tomcat5.5我们需要点“Tomcat Manager”进去管理,
可见是因为权限不对造成的。

知道了问题所在, 我们来解决它,
1.关闭 tomcat5.5
2.打开tomcat-user.xml(在conf文件夹下),添加一个"manager"的权限,并添加一个
登陆名为admin,登陆密码为admin的用户,指定其权限为manager.修改后的tomcat-user.xml如下:


=======================================================

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users> 
       <role rolename="tomcat"/> 
       <role rolename="role1"/> 
       <role rolename="manager"/> 
       <role rolename="admin"/> 
       <user username="tomcat" password="tomcat" roles="tomcat"/> 
       <user username="both" password="tomcat" roles="tomcat,role1"/> 
       <user username="role1" password="tomcat" roles="role1"/> 
       <user username="admin" password="admin" roles="manager"/>
</tomcat-users>
=======================================================


3.保存好tomcat-user.xml,重启动tomcat5.5,
输入:http://127.0.0.1:8080/ 看到熟悉的tomcat界面;
点击“Tomcat Manager”,
输入用户名:admin, 密码admin,看到管理界面