如何重置Jenkins用户ID和密码?以及如何彻底卸载清除备份后重新安装Jenkins以配置新设置?
Absolutely, you can fully wipe Jenkins from your system and start fresh—this is the surest way to get rid of the old login credentials and start over. Let’s break this down into two paths: first, a quick fix to reset your security settings (in case you just want to recover access without full reinstall), and second, the full clean uninstall if you want a totally fresh start.
If you’d rather not reinstall, you just need to find the config.xml file to disable security temporarily, then reset your credentials. Here’s where to look for it on different systems:
- Windows: Check
C:\Program Files\Jenkins\config.xmlorC:\Users\<YourUsername>\.jenkins\config.xml(if Jenkins runs as your user) - Linux: Default path is
/var/lib/jenkins/config.xml - macOS: Look in
/Users/Shared/Jenkins/Home/config.xmlor/Library/Application Support/Jenkins/config.xml
Once you find the file:
- Stop the Jenkins service first (via Services on Windows,
sudo systemctl stop jenkinson Linux,brew services stop jenkinson macOS) - Open
config.xmlin a text editor - Find the line
<useSecurity>true</useSecurity>and change it to<useSecurity>false</useSecurity> - Save the file and restart Jenkins
- When Jenkins loads, you’ll be able to access the dashboard without login. Head to Manage Jenkins > Configure Global Security to re-enable security and set a new admin account.
If you want a totally fresh setup (and couldn’t find the config file), follow these steps to remove every trace of Jenkins from your system:
Windows
- Stop the Jenkins service: Open
services.msc(search for "Services" in the Start menu), find Jenkins, right-click and select Stop - Uninstall Jenkins: Go to Control Panel > Programs > Programs and Features, find Jenkins, and click Uninstall
- Delete residual files:
- Remove the installation directory (default:
C:\Program Files\Jenkins) - Delete the Jenkins home folder: Check
C:\Users\<YourUsername>\.jenkinsorC:\Windows\System32\config\systemprofile\.jenkins(this is where Jenkins stores all your jobs, credentials, and settings) - Remove the service entry: Open Command Prompt as admin and run
sc delete Jenkins
- Remove the installation directory (default:
- Optional: Clean the registry (advanced) - Open
regeditand delete keys underHKEY_LOCAL_MACHINE\SOFTWARE\Jenkins
Linux (Debian/Ubuntu)
- Stop the service:
sudo systemctl stop jenkins - Purge Jenkins (removes the app and configuration files):
sudo apt-get purge jenkins - Delete all residual data folders:
sudo rm -rf /var/lib/jenkins /var/cache/jenkins /var/log/jenkins - Clean up unused dependencies:
sudo apt-get autoremove --purge
Linux (RHEL/CentOS/Fedora)
- Stop the service:
sudo systemctl stop jenkins - Uninstall Jenkins:
sudo yum remove jenkins - Delete residual data:
sudo rm -rf /var/lib/jenkins /var/cache/jenkins /var/log/jenkins - Clean package cache:
sudo yum clean all
macOS
- Stop Jenkins:
- If installed via Homebrew:
brew services stop jenkins - If installed via the official pkg:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
- If installed via Homebrew:
- Uninstall:
- Homebrew:
brew uninstall jenkins - Pkg installer:
sudo rm -rf /Applications/Jenkins
- Homebrew:
- Delete core data folders:
sudo rm -rf /Users/Shared/Jenkins/Home - Remove launch daemon:
sudo rm /Library/LaunchDaemons/org.jenkins-ci.plist - Optional: Clean Homebrew residuals:
brew cleanup jenkins
After completing these steps, reinstall Jenkins normally—you’ll get the initial setup wizard to create a new admin user and configure your instance from scratch.
内容的提问来源于stack exchange,提问作者AshishPuma

