PHP Classes

PHP MySQL User Manager: Manage users that access a MySQL database server

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 231 All time: 8,129 This week: 284Up
Version License PHP version Categories
mysql-user-manager 1BSD License5PHP 5, Databases, Systems administration
Description 

Author

This class can manage users that access a MySQL database server.

It can perform several operations with users with permissions to access databases on a MySQL server. Currently it can:

- Check if a given user exists
- Retrieve the details of a given user
- Create a new user with a given password
- Delete existing user permission to access from a host
- Retrieve granted permissions of an user to access from a host
- Set the password for an user accessing from a host
- Change the host of a user access permission
- Grant or remove privileges for an user to access given database tables

Picture of Garefild
Name: Garefild <contact>
Classes: 2 packages by
Country: Israel Israel
Age: ???
All time rank: 277514 in Israel Israel
Week rank: 312 Up3 in Israel Israel Up

Example

<?php

/** I
 *
 * GGGGG A RRRR EEEEEE FFFFFF I L DDDD
 * G A A R R E F I L D D
 * G GGG A A R RR EEEEEE FFFFFF I L D D
 * G G AAAAAAA R R E F I L D D
 * GGGG A A R R EEEEEE F I LLLLLL DDDD
 *
 * Powered by Garefild
 * @Author Garefild
 * @Copyright 2010-2014
 *
 *
 * ********************************************************************************
 * ** -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- *
 * ** --------------------------------------------------------------------------- *
 * ** PHP index.php - www
 * ** Cerate: 11/15/2014
 * ** Developed by: Garefild <Garefild2@gmail.com> *
 * ********************************************************************************
 *
 */

include ('mysqlUserManager.php');

$users = new MysqlUserManager('localhost', 'root', '', 'db');


/**
 * Checks if a user exists
 * Must use isset
 */

//if(isset($users -> testUsername)) {
// //user exists
//}


/**
 * if testUsername exists (If you are an existing user can manipulate the user)
 * if testUsername not exists (If the user does not exist it creates a new user with the name without a password and server localhost)
 */

//$users -> testUsername;


/**
 * if testUsername exists (If you are an existing user can manipulate the user)
 * if testUsername not exists (If the user does not exist it creates a new user with the name)
 *
 * password the password
 * localhost the server
 */

//$users -> testUsername('password', 'localhost');

/**
 * Changing a user password
 */

//$users -> testUsername -> setPassword('123');


/**
 * Adding user permissions
 * Default Permissions - ALL PRIVILEGES + All the database and all the tables (*.*)
 *
 * ALL PRIVILEGES- as we saw previously, this would allow a MySQL user all access to a designated database (or if no database is selected, across the system)
 * CREATE- allows them to create new tables or databases
 * DROP- allows them to them to delete tables or databases
 * DELETE- allows them to delete rows from tables
 * INSERT- allows them to insert rows into tables
 * SELECT- allows them to use the Select command to read through databases
 * UPDATE- allow them to update table rows
 * GRANT OPTION- allows them to grant or remove other users' privileges
 *
 * @param $privileges
 * @param string $database - database name or * for all database
 * @param string $table - table name or * for all table
 *
 */

//$users -> testUsername -> setPrivileges('ALL PRIVILEGES', 'database', 'table');

/**
 * Remove user permissions
 * Default Permissions - ALL PRIVILEGES + All the database and all the tables (*.*)
 *
 * ALL PRIVILEGES- as we saw previously, this would allow a MySQL user all access to a designated database (or if no database is selected, across the system)
 * CREATE- allows them to create new tables or databases
 * DROP- allows them to them to delete tables or databases
 * DELETE- allows them to delete rows from tables
 * INSERT- allows them to insert rows into tables
 * SELECT- allows them to use the Select command to read through databases
 * UPDATE- allow them to update table rows
 * GRANT OPTION- allows them to grant or remove other users' privileges
 *
 * @param $privileges
 * @param string $database - database name or * for all database
 * @param string $table - table name or * for all table
 *
 */

//$users -> testUsername -> removePrivileges('CREATE, DROP, SELECT, UPDATE', 'database', 'table');

/**
 * delete user
 */

//$users -> testUsername -> delete();

/**
 * if user exists
 */

//if(isset($users -> garefild)) {
//
//} else {
//
//}


$users -> administrator -> setPassword('123') -> setHost('192.168.1.1') -> setPrivileges('CREATE, DROP', 'db', 'members');


  Files folder image Files  
File Role Description
Plain text file mysqlUserManager.php Class Class
Accessible without login Plain text file index.php Example example

 Version Control Unique User Downloads Download Rankings  
 0%
Total:231
This week:0
All time:8,129
This week:284Up
User Comments (1)
Thats a good and useful class ;-)
9 years ago (José Filipe Lopes Santos)
67%StarStarStarStar