Stored Procedures for Creating Accounts

by Valkryst

You should only use one of these procedures if you know SQL and can alter them to work as you wish. They need to be executed on the auth database.

Procedure #1

Creates a player account for the WotLK expansion.

    
        DELIMITER //

        DROP PROCEDURE IF EXISTS create_account;

        CREATE PROCEDURE create_account (usrName VARCHAR(12), pssWd VARCHAR(32))
        BEGIN
         SET @shaPass := SHA1(CONCAT(UPPER(usrName),':',UPPER(pssWd)));
         INSERT INTO account(`username`, `sha_pass_hash`, `expansion`) VALUES(usrName, @shaPass, 2);
         SELECT @accID := `id` FROM account WHERE username = `usrName`;
         INSERT INTO rbac_account_permissions(`accountId`, `permissionId`, `granted`, `realmId`) VALUES(@accId, 195, 1, -1);
        END//

        DELIMITER :
    
  ## Procedure #2 Creates a player account for the specified expansion.
    
        DELIMITER //

        DROP PROCEDURE IF EXISTS create_account;

        CREATE PROCEDURE create_account (usrName VARCHAR(12), pssWd VARCHAR(32), expacType INTEGER)
        BEGIN
         SET @shaPass := SHA1(CONCAT(UPPER(usrName),':',UPPER(pssWd)));
         INSERT INTO account(`username`, `sha_pass_hash`, `expansion`) VALUES(usrName, @shaPass, expacType);
         SELECT @accID := `id` FROM account WHERE username = `usrName`;
         INSERT INTO rbac_account_permissions(`accountId`, `permissionId`, `granted`, `realmId`) VALUES(@accId, 195, 1, -1);
        END//

        DELIMITER :
    

Procedure #3

Creates an account, with the specified GM level on all realms, for the WotLK expansion.

    
        DELIMITER //

        DROP PROCEDURE IF EXISTS create_account;

        CREATE PROCEDURE create_account (usrName VARCHAR(12), pssWd VARCHAR(32), rbacGMLevel INTEGER)
        BEGIN
         SET @shaPass := SHA1(CONCAT(UPPER(usrName),':',UPPER(pssWd)));
         INSERT INTO account(`username`, `sha_pass_hash`, `expansion`) VALUES(usrName, @shaPass, 2);
         SELECT @accID := `id` FROM account WHERE username = `usrName`;
         INSERT INTO rbac_account_permissions(`accountId`, `permissionId`, `granted`, `realmId`) VALUES(@accId, rbacGMLevel, 1, -1);
        END//

        DELIMITER :
    

Procedure #4

Creates an account, with the specified GM level on all realms, for the specified expansion.

    
        DELIMITER //

        DROP PROCEDURE IF EXISTS create_account;

        CREATE PROCEDURE create_account (usrName VARCHAR(12), pssWd VARCHAR(32), expacType INTEGER, rbacGMLevel INTEGER)
        BEGIN
         SET @shaPass := SHA1(CONCAT(UPPER(usrName),':',UPPER(pssWd)));
         INSERT INTO account(`username`, `sha_pass_hash`, `expansion`) VALUES(usrName, @shaPass, expacType);
         SELECT @accID := `id` FROM account WHERE username = `usrName`;
         INSERT INTO rbac_account_permissions(`accountId`, `permissionId`, `granted`, `realmId`) VALUES(@accId, rbacGMLevel, 1, -1);
        END//

        DELIMITER :
    

I haven't tested procedures 2-4, but I don't see anything wrong with them so they should work.