How7o
  • Home
  • Tools
  • Prank Screens
  • Contact
  • Blog
Reading: How to Change a User Password in Laravel
Share
Subscribe Now
How7oHow7o
Font ResizerAa
  • Marketing
  • OS
  • Features
  • Guide
  • Complaint
  • Advertise
Search
  • Home
  • Tools
  • Prank Screens
  • Contact
  • Blog
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.
How7o > Blog > Web Development > How to Change a User Password in Laravel
Web Development

How to Change a User Password in Laravel

how7o
By how7o
Last updated: April 19, 2026
6 Min Read
Laravel user password being updated via artisan tinker with Hash::make
SHARE

Every so often you need to reset a Laravel user’s password manually — they’ve lost access to the email the reset flow sends to, or you’re debugging a staging account, or you’re recovering from an incident. Editing the password column directly in the database with a plain string won’t work (Laravel stores bcrypt hashes). Here are three clean ways to set a new password, picked for different situations.

Contents
  • TL;DR
  • Option 1: Tinker (Best for One-Off Changes)
  • Option 2: A Throwaway Route (When You Don’t Have Shell Access)
  • Option 3: A Custom Artisan Command (Best for Recurring Use)
  • Why Hash::make() and Not password_hash()?
  • Troubleshooting
    • Class “App\User” Not Found
    • Password Change Succeeded But Login Still Fails
    • Call to Undefined Method setPasswordAttribute
  • Frequently Asked Questions
  • Related Guides

Originally published January 23, 2023, rewritten and updated April 17, 2026.

TL;DR

Open php artisan tinker, retrieve the user, assign Hash::make('new-password') to the password attribute, and call save():

$user = App\Models\User::where('email', '[email protected]')->first();
$user->password = Hash::make('new-password');
$user->save();

Option 1: Tinker (Best for One-Off Changes)

If you have SSH access to the server, Tinker is the fastest path. It’s an interactive REPL that boots the full Laravel application, so you have access to every model and facade.

cd /path/to/laravel-project
php artisan tinker

Inside the REPL:

$user = App\Models\User::where('email', '[email protected]')->first();
$user->password = Hash::make('SomeStrongPassword123!');
$user->save();

You can also look up the user by ID — often more reliable if the email is in doubt:

$user = App\Models\User::find(1);

Note on the namespace: Laravel 8 and later ship the User model at App\Models\User. If you’re maintaining a Laravel 6/7 project, the model lives at App\User instead.

Option 2: A Throwaway Route (When You Don’t Have Shell Access)

If you only have access to the codebase (not the server shell), drop a temporary route in routes/web.php:

use App\Models\User;
use Illuminate\Support\Facades\Hash;

Route::get('/__reset-password-temporary', function () {
    $user = User::where('email', '[email protected]')->first();
    abort_if(!$user, 404);
    $user->password = Hash::make('SomeStrongPassword123!');
    $user->save();
    return 'Password updated.';
});

Hit the URL once, then remove the route and deploy again immediately. Leaving it in place — even with an obscure path — is a serious security hole, since the new password is hardcoded and visible to anyone who can read the source.

Three ways to change a Laravel user password: artisan tinker, a temporary route, and a custom artisan command

Option 3: A Custom Artisan Command (Best for Recurring Use)

If you reset passwords often (support workflows, for instance), make a proper Artisan command:

php artisan make:command ResetUserPassword

Edit app/Console/Commands/ResetUserPassword.php:

protected $signature = 'user:reset-password {email} {password}';

public function handle(): int
{
    $user = \App\Models\User::where('email', $this->argument('email'))->first();

    if (!$user) {
        $this->error('User not found.');
        return self::FAILURE;
    }

    $user->password = \Illuminate\Support\Facades\Hash::make($this->argument('password'));
    $user->save();

    $this->info("Password updated for {$user->email}");
    return self::SUCCESS;
}

Usage:

php artisan user:reset-password [email protected] SomeStrongPassword123!

Why Hash::make() and Not password_hash()?

Laravel’s Hash facade wraps PHP’s native password_hash() but uses the driver configured in config/hashing.php — bcrypt by default, argon2id on newer projects. Using Hash::make() ensures the hash is formatted exactly the way auth()->attempt() expects. If you call password_hash() directly with a different algorithm or cost, login checks can silently start failing.

Troubleshooting

Class “App\User” Not Found

You’re on Laravel 8 or later and the model moved to App\Models\User. Update the namespace in your code.

Password Change Succeeded But Login Still Fails

Check that the user’s account isn’t locked by a throttle (users.failed_login_attempts or similar if you’ve added lockout), and that their email is verified if your app enforces email verification on login. Also look at whether the User model has a custom mutator on password — assigning the already-hashed value to a column that also hashes on set would double-hash it.

Call to Undefined Method setPasswordAttribute

Only relevant if a previous developer added a custom setPasswordAttribute mutator that calls Hash::make() automatically. In that case, assigning Hash::make($plain) hashes twice. Assign the plain value and let the mutator do its job.

Frequently Asked Questions

How do I change a user’s password in Laravel without a login?

Open <code>php artisan tinker</code>, retrieve the user, assign <code>Hash::make(‘new-password’)</code> to <code>$user->password</code>, and call <code>$user->save()</code>. No login or email flow required.

Should I use Hash::make() or PHP’s password_hash() in Laravel?

Use <code>Hash::make()</code>. It respects the driver in <code>config/hashing.php</code> (bcrypt or argon2id), so hashes match what Laravel’s <code>Auth::attempt()</code> expects. Calling <code>password_hash()</code> directly risks algorithm mismatches that break login.

Is the User model App\User or App\Models\User?

On Laravel 8 and later, it’s <code>App\Models\User</code>. On Laravel 6/7 it’s <code>App\User</code>. Check the top of <code>routes/web.php</code> or <code>config/auth.php</code> if you’re unsure which your project uses.

Is it safe to change a password with a temporary route?

Only if you remove the route immediately after use. A route that sets any user’s password based on a hardcoded email is a credential reset vulnerability — leave it in place and anyone who finds the URL can take over the account.

Related Guides

  • How to Check if a Record Exists in Laravel
  • How to Use the Laravel Validator Exists Rule
  • How to Install Laravel

For more on Laravel’s password hashing, see the official Laravel hashing documentation.

TAGGED:EloquentLaravelphpSecurity

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Deleting a Laravel user cascades to remove related posts, photos, and notifications How to Delete Related Records in Laravel Eloquent
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow

Subscribe Now

Subscribe to our newsletter to get our newest articles instantly!
Most Popular
Laravel user password being updated via artisan tinker with Hash::make
How to Change a User Password in Laravel
April 19, 2026
Deleting a Laravel user cascades to remove related posts, photos, and notifications
How to Delete Related Records in Laravel Eloquent
April 19, 2026
Laravel migration converting a MySQL column type from VARCHAR to DECIMAL without losing data
How to Change a MySQL Column Type in Laravel Migration
April 19, 2026
Laravel migration adding two new columns to an existing transactions table
How to Add New Columns to an Existing Table in Laravel Migration
April 19, 2026
Laravel foreign key constraint linking posts.user_id to users.id in a schema diagram
How to Add Foreign Keys in Laravel Migration
April 19, 2026

You Might Also Like

Create custom exception class in Laravel (Artisan command + secure error handling)
Web Development

How to Create a Custom Exception Class in Laravel (With Clean JSON Responses)

6 Min Read
Check if Laravel scheduler is running (cron + php artisan schedule:run)
Web Development

How to Check if Laravel Scheduler Is Running (Cron + Logs)

6 Min Read
Debug PHP like console.log using error_log and server logs
Web Development

How to Debug in PHP Like console.log (echo, error_log, WordPress debug.log)

6 Min Read
Dynamically set site title and tagline in WordPress by country
Web Development

How to Dynamically Set Site Title and Tagline in WordPress (By Country)

6 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Latest News

  • SEO Audit Tool
  • Client ReferralsNew
  • Execution of SEO
  • Reporting Tool

Resouce

  • Google Search Console
  • Google Keyword Planner
  • Google OptimiseHot
  • SEO Spider

Get the Top 10 in Search!

Looking for a trustworthy service to optimize the company website?
Request a Quote
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?