I recommend you do NOT use the MySQL PASSWORD() function. Read the documentation. It says:
PASSWORD() is used by the authentication system in MySQL Server; you should not use it in your own applications.
This function is officially deprecated in MySQL 5.7.6, and by MySQL 8.0.11, the PASSWORD() function has been removed. You can't upgrade to the current version of MySQL if you depend on the PASSWORD() function.
It's a bad idea to use any function in SQL to hash passwords, because if you do that, the plaintext passwords (that is, before hashing) will appear in your query logs and statement-based binary logs. That's a security weakness in your app that any auditor would demand you change.
Instead, the better way to do password hashing in PHP is to use password_hash() when storing the password, and password_verify() when a login needs to check input against the stored password.
If you're using Laravel, look into using the Hash class: https://laravel.com/docs/6.x/hashing
Regarding your comment on another answer:
as i said, its for an old game and we cant change how the password is encrypted. otherwise i would ofc use the hash method.
You need to fix this, or retire the game. It's not secure.
You can change how an app stores passwords. I've done it in some apps I've written. You can't reverse hashing, so you can't convert existing passwords to the new format, but the way to do it is to develop code to handle both cases. The code should work in the following way:
- Add a new column in your accounts table to store the new password-hash format.
- When a user logs in, check the user's input against the old password hash, as you would normally. That is, hash the user's input and compare the result to what's stored in the database.
- If the hash of the user's input matches the hash, then UPDATE the database: store the new-format hash in the new password column, and assign NULL to the old password column.
- Change the login code so it fetches both columns, and if the old password column is NULL, then hash the user input with the new method and compare that to the new password column.
Gradually, as each user logs in, their passwords will be "upgraded." Once they are all upgraded, drop the old password column and simplify your login code to remove the old hashing method.
It's possible that there will be some straggler users who never log in for weeks or months. Don't wait for them. When all the regular users have converted their passwords, just drop the old passwords. The straggler users will have to do password recovery if they ever come back.