
DROP SCHEMA IF EXISTS `inf340tpdb` ;
CREATE SCHEMA IF NOT EXISTS `inf340tpdb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `inf340tpdb` ;

DROP PROCEDURE IF EXISTS inf340tpdb.drop_user_if_exists ;
DELIMITER $$
CREATE PROCEDURE inf340tpdb.drop_user_if_exists()
BEGIN
  DECLARE foo BIGINT DEFAULT 0 ;
  SELECT COUNT(*)
  INTO foo
    FROM mysql.user
      WHERE User = 'etudiant' and  Host = 'localhost';
   IF foo > 0 THEN
         DROP USER 'etudiant'@'localhost' ;
  END IF;
END ;$$
DELIMITER ;

CALL inf340tpdb.drop_user_if_exists() ;
DROP PROCEDURE IF EXISTS inf340tpdb.drop_users_if_exists ;



CREATE USER 'etudiant'@'localhost' IDENTIFIED BY 'perdu';
GRANT ALL PRIVILEGES  ON inf340tpdb.* TO 'etudiant'@'localhost'
 WITH GRANT OPTION

