How to Properly Reset a Laravel User Password
In this guide
Laravel uses Bcrypt to securely hash passwords, meaning you can’t just type a new plain-text password directly into the database. It must be hashed using Laravel’s built-in functions. Follow these steps to correctly reset a user’s password from the terminal.
Step 1: Log in to cPanel
Access your cPanel account through your hosting provider.
Step 2: Open the Terminal
- In cPanel, scroll down to the Advanced section.
- Click on Terminal to launch the command line interface.
Step 3: Navigate to Your Laravel Project
Use the following command to go to the Laravel directory:
cd public_html
Modify the path if your Laravel project is in a different directory.
Step 4: Launch Laravel Tinker
Enter the following command:
php artisan tinker
You should now see a console prompt that looks like this:
>>>
Step 5: Generate the Hashed Password
At the Tinker prompt, type the command below:
echo Hash::make('your-new-password');
Replace your-new-password with the password you want to use.
Example:
echo Hash::make('MySecurePass123');
You’ll get an output like this:
$2y$10$GTP5DRX5IBTH9iCikZV7zeKHZeRC9EHP28Hs2LaHBGC9oZkTaHKfW
Copy this hashed password — you’ll need it for the next step.
Step 6: Update the Password in the Database
- Open phpMyAdmin from cPanel.
- Select your Laravel project’s database.
- Click on the users table.
- Find the user you want to update.
- Paste the hashed password into the password field.
- Click Save or Go to apply the changes.
Step 7: Test the New Password
You can now log in to your Laravel app with the user’s email or username and the new password.
Important Tips
- Never insert plain-text passwords into the database.
- Always use Laravel’s hashing to maintain security.
- This method is suitable for both development and production environments.
Keep reading
How to Safely Change SSH Port in AlmaLinux (e.g., to 2022)
Changing the default SSH port (22) helps protect your server from automated attacks. In this guide, we’ll show you how to change the SSH port safely and open the new...
How to migrate all cPanel accounts using the terminal?
If you’re switching servers entirely and want to bring over every single cPanel account, this guide is for you. It’s a bit more time-consuming, but still very...
How to migrate a single cPanel account to a new server?
Moving a website to a new server can feel intimidating, but don’t worry — we’ve got you covered. In this guide, you’ll learn how to move a single cPanel account to a new...