sqlmysqlauthenticationstored-procedurespasswords

I am trying to create a stored procedure to check passwords of logins


I want to create a SQL stored procedure that checks passwords at login. This should be a very common question however I could not find an answer anywhere to my specific question, which is about data types, or perhaps something like that. I am using a MySQL database but I am unsure what type of SQL I am using specifically. Here's my SQL:

CREATE PROCEDURE SelectAllUsers @Password varchar(12)
AS
SELECT * FROM Logins WHERE Password = @Password
GO;

This image shows where I get an error for some reason, which is beyond me


Solution

  • If you are using MySQL, navigate to Stored Procedure under you DB Schema, right click and then click 'Create Stored Procedure'. Copy below query. Change definer (root@localhost) accordingly.

    CREATE DEFINER=`root`@`localhost` PROCEDURE `SelectAllUsers`(IN in_password VARCHAR(12))
    BEGIN
    SELECT * FROM Logins WHERE Password = in_password;
    END