How to create, rename, and drop users

How to create a user from a specific host

      CREATE USER joel@localhost IDENTIFIED BY 'sesame'; 
      

How to create a user from any host

      CREATE USER dba IDENTIFIED BY 'sesame'; --creates 'dba@%'
      

How to rename a user from a specific host

      RENAME USER joel@localhost TO joelmurach@localhost;
      

How to change a user’s password

      GRANT USAGE ON *.* TO joelmurach@localhost IDENTIFIED BY 'newpassword';
      

How to drop a user from a specific host

      DROP USER joelmurach@localhost;
      

How to drop a user from any host

      DROP USER dba; --drops 'dba@%'
      

Description

Back