buy
Add Database User To Database

Description

You can use this  API to Add Database User To Database in your Webuzo panel.

Parameters

Array Of Privilege

Set privileges to the database user

array (
  'SELECT' => 'Y',
  'CREATE' => 'Y',
  'INSERT' => 'Y',
  'UPDATE' => 'Y',
  'ALTER' => 'Y',
  'DELETE' => 'Y',
  'INDEX' => 'Y',
  'CREATE_TEMPORARY_TABLES' => 'Y',
  'EXECUTE' => 'Y',
  'DROP' => 'Y',
  'LOCK_TABLES' => 'Y',
  'REFERENCES' => 'Y',
  'CREATE_ROUTINE' => 'Y',
  'ALTER_ROUTINE' => 'Y',
  'EVENT' => 'Y',
  'CREATE_VIEW' => 'Y',
  'SHOW_VIEW' => 'Y',
  'TRIGGER' => 'Y',
)

Sample Code

curl --insecure -d "submitpri=1" -d "dbname=database_name" -d "dbuser=database_user" -d "host=host" -d "pri[SELECT]=Y" -d "pri[CREATE]=Y" -u "username:password" -X POST "https://Server Ip or Hostname:2003/index.php?api=json&act=dbmanage"
<?php
	$user = 'Username';
	$pass = 'Password';
	$host = 'Server Ip or Hostname';
	 
	$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$host.':2003/index.php?api=json&act=dbmanage'; 

	$post = array('submitpri' => '1',
              'dbname' => 'database_name',
              'dbuser' => 'database_user',
              'host' => 'localhost',
              'pri' => array (
			  'SELECT' => 'Y',
			  'CREATE' => 'Y',
			  'INSERT' => 'Y',
			  'UPDATE' => 'Y',
			  'ALTER' => 'Y',
			  'DELETE' => 'Y',
			  'INDEX' => 'Y',
			  'CREATE_TEMPORARY_TABLES' => 'Y',
			  'EXECUTE' => 'Y',
			  'DROP' => 'Y',
			  'LOCK_TABLES' => 'Y',
			  'REFERENCES' => 'Y',
			  'CREATE_ROUTINE' => 'Y',
			  'ALTER_ROUTINE' => 'Y',
			  'EVENT' => 'Y',
			  'CREATE_VIEW' => 'Y',
			  'SHOW_VIEW' => 'Y',
			  'TRIGGER' => 'Y',
			) 
	        );

	// Set the curl parameters 
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

	if(!empty($post)){
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
	}

	// Get response from the server. 
	$resp = curl_exec($ch);
	if(!empty(curl_error($ch))){
		echo curl_error($ch); die();
	}

	// The response will hold a string as per the API response method. 
	$res = json_decode($resp, true);
	// Done ?
	if(!empty($res['done'])){
		echo "<pre>";
		print_r($res['done']['msg']);
		echo "</pre>";
	}else{
		print_r($res['error']);
	}
?>

Output

Database Privileges Updated

    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list