user_mysql_mgmt.pl -- MySQL user management script


NAME

user_mysql_mgmt.pl - MySQL user management script


SYNOPSIS

 user_mysql_mgmt.pl
 user_mysql_mgmt.pl --config=


DESCRIPTION

You have to invoke user_mysql_mgmt.pl always with --config=. The script will parse the configuration file and add/delete or modify the MySQL user tables in the mysql database.


OPTIONS

 The options which apply to the user_mysql_mgmt.pl command are:
--verbose
 Verbose: print information messages about all actions.
--help,-h
 Help: print help and exit.
--config=
 Config: Supply an configuration to the script.
--set-password
 Set-Password: Set an new hashed password in the configuration file.
 You have to supply with B<--user=> the username.
--user=
 User: Supply an username for changing the password. Please see B<--set-password>.
--mysql-old-hashing
 MySQL-Old-Hashing: Use the old MySQL 3.x password hashing.


CONFIGURATION

The script needs one MySQL user with global privileges: Reload,Grant,Create user. This user needs also SELECT,INSERT,UPDATE,DELETE privileges at database mysql.*.

You can use the following GRANT statement:

  GRANT RELOAD , CREATE USER ON * . * TO 'myadmin'@'localhost' IDENTIFIED BY 'your-password'  WITH GRANT OPTION ;
  GRANT SELECT,INSERT,UPDATE,DELETE ON `mysql` . * TO 'myadmin'@'localhost';

The username and password of your control user needs to be stored in your configuration file.


SAMPLE COMMANDS

./user_mysql_mgmt.pl --config=user_mysql_mgmt.conf --set-password --user=foo@locahost
   This command will update the hashed password for user foo@localhost in the configuration file.
   Please note, you have run after this update password command the normal run with:
      ./user_mysql_mgmt.pl --config=user_mysql_mgmt.conf
   This will update the new password into MySQL tables.


SAMPLE CONFIGURATION FILE

   # global settings
   <global>
       # username,password for the control user
       mysql_host   localhost
       mysql_password   your-password
       mysql_user   admin
   </global>
   <users>
       <foo>
           host   localhost
           # If password is not supplied, password will not be updated by the script!
           password   *6A7A490FB9DC8C33C2B025A91737077A7E9CC5E5
           <db>
                   foo:select,update,insert
                   one_more_db:delete,drop,show_view
           </db>
       </foo>
       <jonas>
           # put active 0: user will be deleted on the next run!
           active   1
           <db>
           </db>
           global_privs   select,drop
           host   %
           password
       </jonas>
   </users>


ENVIRONMENT

 No environment variables are used.


LICENSE AND COPYRIGHT

 Copyright (c) 2009 Jonas Genannt
 This script is free software; you can redistribute it and/or
 modify it under the terms of GPL.


AUTHOR

 Jonas Genannt <jonas@brachium-system.net>
 user_mysql_mgmt.pl -- MySQL user management script