MySQL query limit per hour with database user creation

Discussion in 'Installation/Configuration' started by czdavid, Jan 15, 2013.

  1. czdavid

    czdavid New Member

    Hello,

    I need set MySQL query limit per hour and max_user_connections with creation MySQL user by ISPCONFIG. Is it possible?

    Thank you!!!
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    This should be possible but you will have to change the code of the mysql plugin that creates the user to set these additional parameters.
     
  3. czdavid

    czdavid New Member

    Thank you! Where I can find part of code which I have to change?
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    The plugins are in /usr/local/ispconfig/server/plugins-available/ There ist just one plugin with mysql in its name.
     
  5. czdavid

    czdavid New Member

    Thank you Till. You are very helpful :)
     
  6. czdavid

    czdavid New Member

    Till can you check if is it right, please?
    I´m not sure, if it is right place in source.

    I use $usage_limit variable for define mysql limits.
    $usage_limit variable is put two lines down bellow is defined.

    Code:
               // Create the database user if database is active
    			if($data['new']['active'] == 'y') {
    				
    				if($data['new']['remote_access'] == 'y') {
              $this->process_host_list('GRANT', $data['new']['database_name'], $data['new']['database_user'], $data['new']['database_password'], $data['new']['remote_ips'], $link);
    				}
    				$usage_limit = 'WITH MAX_QUERIES_PER_HOUR 100000 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 10';
    				$db_host = 'localhost';
    				mysql_query("GRANT ALL ON `".str_replace(array('_','%'),array('\\_','\\%'),mysql_real_escape_string($data['new']['database_name'],$link))."`.* TO '".mysql_real_escape_string($data['new']['database_user'],$link)."'@'$db_host' IDENTIFIED BY PASSWORD '".mysql_real_escape_string($data['new']['database_password'],$link)."' ".$usage_limit.";",$link);
    
    				
    			}
    
     

Share This Page