I am using Laravel 8. I want to change the login password.
I can change it by using this code: $login->pass = Hash::make($pass);
Instead of the code, how can I change the user password using PHPMyAdmin?
CodePudding user response:
You just need to use the same algorithm to do the hashing and then you can insert that hash into the database and it will work fine. By default Laravel is using 'bcrypt'. You can use something like http://bcrypt.online to create a hash from the plain text password. You can update the password with that value in the database and you are set.
I haven't used phpMyAdmin in a long time but if it has the option to hash a field for you in its interface, just use 'bcrypt'.
CodePudding user response:
To change user's password using PHPMyAdmin you should
- open PHPMyAdmin in your browser;
- open table list for your db (press plus in front of it);
- open the users table;
- find the user which password you wanna change;
- press twice in the password field and fill it with value you want;
- press outside of the field to save changes.
But in this case you will not be able to log in on the site, because when you submit a password on the site, laravel hashes the password entered and compares it with the password from the db. Hashed password != password in pure form (that you entered using PHPMyAdmin) => you can't log in. So to be able to log in on the site you should enter hashed password using PHPMyAdmin.
You can try to find the hash algorithm which laravel uses, to hash your password online and then save it using PHPMyAdmin.
You can change authentication in laravel so that it does not cache password before comparing. (This is unsafe way, because you have to store your passwords in pure form)
You can change user's password with the code by creating your custom artisan console command (https://laravel.com/docs/8.x/artisan#writing-commands). You can create command which takes a password and user id as parameters, hashes your password and save it for the user.
