Thursday, August 3, 2023

How to Reset the Laravel Application's Forgotten Password when we have access to Database?


Run this below command to create a Controller

php artisan make:controller TestController


This will create a TestController.php in your controller directory and copy the BOLD text to file created.

<?php


namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Hash;

use Illuminate\Support\Facades\DB;

class TestController extends Controller

{

    public function ResetAdminPassword()

    {

//Assume user id of admin is 1

$user_id=1;

        $myNewPassword='P@ssword';

$password = Hash::make($myNewPassword);

  DB::table('users')->where('id', '=', $user_id)->update([

                'password' => $password 

        ]);

    }

}

 

XAMPP MySql Crash issue

 This is as a result of some files in C:\xampp\mysql\data\mysql getting corrupted. Solution: Back up C:\xampp\mysql\data Copy all file C:\xa...