Tomcat安装成功,无法进入管理页面的解决方法

mac电脑安装了tomcat,安装在/Library/Tomcat
终端:cd /Library/Tomcat/bin 执行:./startup.sh,提示Tomcat started.
浏览器打开http://localhost:8080/,能正常访问tomcat的首页,点击“Server Status”“Manager App”“Host Manager”都要求输入管理账号和密码,之前在网络上搜索的安装教程指明,打开/conf/tomcat-users.xml,输入如下:

<role rolename="manager-gui"/>
<user username="tomcat" password="mimimama" roles="manager-gui"/>

重启tomcat后,用上面代码中的账号和密码还是登陆不进去,返回401错误提示。

.

解决方法是,打开/conf/tomcat-users.xml,把整个文件的代码更换为:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="你的登录用户名" password="你的密码" roles="admin-gui,manager-gui"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
</tomcat-users>

备注:
<rolerolename="admin-gui"/>角色只可以进行Host Manager管理,不能进行Server Status和Manager App管理;<rolerolename="manager-gui"/>角色可以进行ServerStatus和 Manager App管理(不能进行Host Manager管理);

重新启动Tomcat ,在登录时使用 用户名、密码登录即可。