MySQL database setup & user creation commands

Login as root user with below command.
mysql -u root -p

Create database with below command.
CREATE DATABASE db_name;

Check database using command.
show databases;

Create user using command.
CREATE USER ‘username’@’%’ IDENTIFIED BY ‘password’;

Grant privileges to the created user.
GRANT ALL PRIVILEGES ON db_name.* TO ‘username’@’%’ WITH GRANT OPTION;
than
FLUSH PRIVILEGES;

Check grants using command.
SHOW GRANTS FOR ‘username’@’%’;

————————————–

Logging in a specific db port
mysql -h hostname -P port -u username -p db_name

show table information, like engine, version, row_format_rows etc.
SHOW TABLE STATUS WHERE Name = ‘tbl_name’

change table storage engine
ALTER TABLE tbl_name ENGINE=NDBCLUSTER;

Show current DB Port:
SHOW VARIABLES WHERE Variable_name = ‘port’;
or
netstat -nat |grep :3306
(Instead 3306 you can mention your port number that you are finding)

Show current mysql user:
SELECT USER();

Data from URL to Web service Client (REST) Drupal

$json = drupal_http_request('http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false');
$decode = json_decode($json->data, TRUE);

Using cURL

$url = 'http://localhost/rest/04/library/book.php';
$client = curl_init($url);
curl_setopt($client, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($client);
curl_close($client);

Consume REST web service in code using Web service client
https://www.drupal.org/node/1114320

$service = wsclient_service_load('your ws service');
  
  $account = new stdClass;
  $account->name ='your user';
  $account->pass_raw ='your pass';
  
  // For own HTTPS certificates.
  $curl_options[CURLOPT_SSL_VERIFYPEER] = FALSE;
  // For own HTTP authorization.
  $curl_options[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC;
  $curl_options[CURLOPT_USERPWD] = $account->name . ':' . $account->pass_raw;
  $service->settings['curl options'] = $curl_options;
  
  try {
    $result = $service->your_method();
  }
  catch (WSClientException $e) {
    watchdog('wsclient', $e->__toString());
    return null;
  }

  return $result;