Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually creating laravel hash directly in SQL

Tags:

mysql

laravel

I have a site where user passwords are hashed using Laravel's Hash::make() function.
I now have a need to manually create user's directly in the DB (MySQL). Is there a way I can create the hashed password for the user using just raw SQL?

like image 919
MakkyNZ Avatar asked Feb 09 '15 11:02

MakkyNZ


2 Answers

You can create the password that you want via php artisan tinker:

  1. Open the terminal on the root of your project.
  2. Then write php artisan tinker.
  3. Then echo Hash::make('password');

You will see the hashed password. You can do whatever you want with that password, even with sql query directly.

like image 186
Panagiotis Koursaris Avatar answered Sep 30 '22 18:09

Panagiotis Koursaris


Not really, I'm afraid. Laravel uses Bcrypt, which isn't available in MySQL. In addition, it's a bad practice to do it in raw SQL, because the passwords might end up in server query logs. Sorry. :/

like image 41
Joel Hinz Avatar answered Sep 30 '22 16:09

Joel Hinz