coding hint

How to connect to remote MySql server

Submitted by admin on Sun, 02/18/2018 - 16:49

To do so you should enable connection from the remote server.

In DirectAdmin:

go to "MySQL Management"  and click on each domain name you want to have access remotely, in section "Access Hosts" below the page you should add the IP address of the remote server and then click on the "Add Host" button.


In command line:

login to your MySQL console with root access

mysql -u root -p

then run the following command:

How to backing up database by its table and restore them to new database

Submitted by admin on Thu, 02/15/2018 - 12:30

for creating separated files for each table:

for x in `mysql --skip-column-names -u <source_username> -p<source_password> <source_database_name> -e 'show tables;'`;
     echo "file=$x"
     mysqldump -u <source_username> -p<source_password> <source_database_name> $x > "$x.sql"


for restoring all .sql files that we have been created in the previous step to our new database

some of functions for working with drupal user

Submitted by admin on Tue, 01/17/2017 - 18:11

here are some functions and useful instructions for working with the drupal user entity.


# for modifying a user for example "user roles" :

  // Remove this role from the user's list.
  $roles_list = $account->roles;

  $account = user_save($account, array('roles' => $roles_list));


# function "user_load" returns an object that you can find it in this article