MySQL - CREATE DATABASE AND USER

-- Create fresh database
CREATE DATABASE drupal7_db;

-- Create a new MySQL user with specific password
CREATE USER drupal7_dbuser@localhost IDENTIFIED BY 'a2NUpXBffCYUHP6a';

-- Give full access to new MySQL user to new database just created
GRANT ALL PRIVILEGES ON drupal7_db.* TO 'drupal7_dbuser'@'localhost';

-- Rebuild privileges to make persistent those changes
FLUSH PRIVILEGES;

 


PostgreSQL - Sequence Manipulation Functions

-- Retrive current sequence value
SELECT last_value FROM <sequence_name>;

-- Update sequence value
SELECT setval('sequence_name',1000);

 


Drupal 7 - MySQL SELECT variable Table

-- Retrieve site name stored into variable table directly from SQL
SELECT name, CONVERT (value USING utf8) 
FROM `variable` 
WHERE name = 'site_name'

 


Update drupal/core Composer

# Verify pending updates
composer outdated drupal/*

# Update drupal core and dependencies
composer update drupal/core --with-dependencies

# Drupal site using drupal-composer/drupal-project
composer update drupal/core webflo/drupal-core-require-dev --with-dependencies

# Once I was forced to remove composer.lock and vendor/ then redo composer update with dependencies
rm -Rf composer.lock vendor/

 


Update-Database NuGet Package Manager on Azure

Firstly setup properly Azure DB firewall, then execute the following command within you Visual Studio,

 Update-Database -Configuration {Project_Namespace}.Migrations.Configuration -Verbose -ConnectionString "Server=tcp:{Azure_SQL_Server}.database.windows.net,1433;Initial Catalog={Azure_DB_Name};Persist Security Info=True;User ID={Azure_DB_Username};Password={Azure_DB_Password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" -ConnectionProviderName "System.Data.SqlClient"

 


Ifconfig inet addresses | nmap scan

ifconfig

/sbin/ifconfig | grep 'inet addr:' 

nmap

nmap -sP 192.168.1.0/24

Kill all processes on particular port

kill -9 $(lsof -t -i:4200)

 


Install your public key in a remote machine's authorized_keys

ssh-copy-id -i root@ip_address

 


Tar Linux Usage

Create compress files

tar -czvf NEW_FILE_NAME.tar.gz /PATH/TO/DIRECTORY-OR-FILE-TO-COMPRESS

Extract files

tar -xzvf FILE_NAME.tar.gz -C /tmp

 


Drupal 8 format date

\Drupal::service('date.formatter')->format($timestamp, $type, $format, $timezone, $langcode);
/* $type:  - One of the built-in formats: 
 *  'short', 'medium', 'long', 'html_datetime', 'html_date', 
 *  'html_time', 'html_yearless_date', 'html_week', 'html_month', 'html_year'. 
 */