Wednesday, November 6, 2024

.::: Install Oracle 12C in Centos 8 :::.

 1. Update Sistem <optional>

sudo dnf update -y

2. Install package

sudo dnf install -y binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libX11 libXau libXi libXtst libXrender libXrender-devel libgcc libstdc++ libstdc++-devel libxcb make smartmontools sysstat

3. Create user & Group

sudo groupadd oinstall
sudo groupadd dba
sudo useradd -g oinstall -G dba oracle
sudo passwd oracle

Thursday, October 31, 2024

.::: Sample Database ERP (Enterprise Resource Planning) and sample query using Join in PostgreSQL EDB :::.

Berikut ini adalah contoh pembuatan database ERP yang lebih sederhana dengan fokus pada customers dan products, serta tabel tambahan orders untuk mengaitkan data pelanggan dengan produk yang mereka pesan. Setiap tabel akan diisi dengan minimal 10 baris data.

A. Sample DB ERP

1. Create Database ERP
CREATE DATABASE TEGUHTH_ERPDB;
USE TEGUHTH_ERPDB;


2. Create Tabel customers
CREATE TABLE customers (
    customer_id SERIAL PRIMARY KEY,
    customer_name VARCHAR(100) NOT NULL,
    email VARCHAR(100) UNIQUE,
    phone VARCHAR(15),
    address TEXT,
    created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
);

.::: Sample Database ERP (Enterprise Resource Planning) and sample query using Join in MariaDB MySQL :::.

Berikut ini adalah contoh pembuatan database ERP yang lebih sederhana dengan fokus pada customers dan products, serta tabel tambahan orders untuk mengaitkan data pelanggan dengan produk yang mereka pesan. Setiap tabel akan diisi dengan minimal 10 baris data.

1. Create Database ERP
CREATE DATABASE TEGUHTH_ERPDB;
USE TEGUHTH_ERPDB;

2. Create Tabel customers
CREATE TABLE customers (
    customer_id INT AUTO_INCREMENT PRIMARY KEY,
    customer_name VARCHAR(100) NOT NULL,
    email VARCHAR(100) UNIQUE,
    phone VARCHAR(15),
    address TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Tuesday, October 1, 2024

.::: Check Date when Microsoft SQL Server (MSSQL), MariaDB MySQL & PostgreSQL Installed & Upgraded :::.


1. MSSQL
 
SELECT @@servername as ServerName,SERVERPROPERTY('productversion') as ProductVersion
      ,SERVERPROPERTY ('productlevel') as ProductLevel
      ,SERVERPROPERTY ('edition') as Edition
      ,SERVERPROPERTY ('MachineName') as MachineName
      ,SERVERPROPERTY ('LicenseType') as LicenseType
      ,SERVERPROPERTY ('NumLicenses') as NumLicenses
      ,create_date as 'SQLInstallDate'
      ,(select modify_date from sys.server_principals where name like '%##MS_SQLAuthenticatorCertificate##%') as SQLUpgradeDate
FROM sys.server_principals
WHERE name='NT AUTHORITY\SYSTEM';

 


2. MariaDB MySQL

Thursday, September 26, 2024

.::: Backup All User, Specify User , Permission, Roles, Server Roles in SQL Server :::.

 
Untuk melakukan backup user dan privilege di SQL Server, Anda bisa menggunakan perintah Transact-SQL (T-SQL) untuk mengekstrak informasi tentang pengguna (user) dan hak akses (privilege). Berikut langkah-langkah yang dapat dilakukan:

1. Backup User Login dan Mapping ke Database

Gunakan skrip di bawah ini untuk mencadangkan login pengguna dan mappingnya ke database.
Output dari skrip ini akan memberikan Anda perintah untuk membuat ulang login yang sudah ada. Perhatikan bahwa password tidak dapat diekstrak, jadi Anda perlu memasukkannya secara manual saat melakukan restore.

-- Backup logins
SELECT @@servername as ServerName,'CREATE LOGIN [' + l.name + '] '
    + CASE
        WHEN l.type_desc = 'SQL_LOGIN' THEN 'WITH PASSWORD = ''<password>'', '
        WHEN l.type_desc = 'WINDOWS_LOGIN' THEN 'FROM WINDOWS, '
        ELSE ''
      END
    + ' DEFAULT_DATABASE=[' + l.default_database_name + ']'
    + CASE
        WHEN l.is_disabled = 1 THEN ', DISABLE;'
        ELSE ';'
      END AS CreateLoginScript
FROM sys.server_principals l
WHERE l.type IN ('S', 'U');  -- SQL Logins (S) and Windows Logins (U)
 

Friday, August 23, 2024

.::: Enable collect MariaDB User login Connect & Disconnect include prviledge using MariaDB Audit :::.

1. enable MariaDB Audit

http://teguhth.blogspot.com/2022/08/enable-server-audit-in-mariadb-mysql.html

2. convert to table

http://teguhth.blogspot.com/2022/09/load-log-file-insert-into-table-in.html

3. check filter tbl_mariadb_audit to filter connect & disconnect

MariaDB [teguhthtools]> select * from tbl_mariadb_audit where type ='connect' or type ='disconnect';
+-------------------+---------+--------+-----------+------+---------------+------------+------+---------+--------+
| date              | host    | userdb | client    | id   | connection_id | type       | db   | sqltext | status |
+-------------------+---------+--------+-----------+------+---------------+------------+------+---------+--------+
| 20240822 07:52:09 | teguhth | admin  | teguhth   |    4 |             0 | CONNECT    |      |         | 0      |
| 20240822 07:52:32 | teguhth | admin  | teguhth   |    4 |             0 | DISCONNECT |      |         | 0      |
+-------------------+---------+--------+-----------+------+---------------+------------+------+---------+--------+
3 rows in set (0.001 sec)

MariaDB [teguhthtools]>

Tuesday, August 20, 2024

.::: Script Broadcast Query in EDB / PostgreSQL to Multple Database in Linux :::.


1. create database sample
create database db_klt_teguh;
create database db_klt_teguh_dmart;
create database db_klt_teguh_archive;

create database db_bgr_tri;
create database db_bgr_tri_dmart;
create database db_bgr_tri_archive;

create database db_lpg_raju;
create database db_lpg_raju_dmart;
create database db_lpg_raju_archive;

.::: Script Broadcast Query in MariaDB MySQL to Multple Database in Linux :::.

1. create database sample
create database db_klt_teguh;
create database db_klt_teguh_dmart;
create database db_klt_teguh_archive;

create database db_bgr_tri;
create database db_bgr_tri_dmart;
create database db_bgr_tri_archive;

create database db_lpg_raju;
create database db_lpg_raju_dmart;
create database db_lpg_raju_archive;

Tuesday, July 30, 2024

.::: How to enable the MySQL/MariaDB general query logs :::.


1. enable general log temporary

SET GLOBAL general_log_file='/var/lib/mysql/general.log';
SET GLOBAL log_output = 'FILE,TABLE';
SET GLOBAL general_log = 'ON';
SET GLOBAL general_log = 1;

 

Sunday, July 14, 2024

.::: Create User Access MariaDB MySQL using PAM example OS Linux Login :::.

 
1. install pam plugin

INSTALL PLUGIN pam SONAME 'auth_pam';

MariaDB [(none)]> INSTALL PLUGIN pam SONAME 'auth_pam';
ERROR 1968 (HY000): Plugin 'pam' already installed
MariaDB [(none)]>


2. check plugin pam

show plugins
SELECT plugin_name,plugin_version,plugin_status,plugin_type,plugin_library,plugin_author FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE '%pam%';

Saturday, July 6, 2024

.::: Script Backup Full + Differential + Transaction Log in MariaDB MySQL & Scheduler just like SQL Server for SingleDB & MultipleDB include Restore in One File Script :::.

 
A. SingleDB

1. run script one time to full backup

sh /data/script/scriptbackup/backup_full_log_single_db.sh
 

2. run script two time to log backup

sh /data/script/scriptbackup/backup_full_log_single_db.sh

Thursday, June 20, 2024

.::: How to configure Transparent Data Encryption (TDE), Monitoring & Remove TDE in SQL Server :::.


A. Create TDE

1. Create Master Key

USE Master;
GO
CREATE MASTER KEY ENCRYPTION
BY PASSWORD='TDEpassword!';
GO

 
 
2. Create Certificate protected by master key
CREATE CERTIFICATE TDE_Cert
WITH
SUBJECT='Database_Encryption';
GO

Sunday, May 19, 2024

.::: Additional Environment PostgreSQL EDB example pg_ctl: command not found :::.

 1. Run pg_ctl

pg_ctl
[root@teguhth ~]# su - postgres
Last login: Sun May 12 08:18:13 WIB 2024 on pts/1
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data status
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data start
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$ pg_ctl -D /var/lib/pgsql/15/data stop
-bash: pg_ctl: command not found
-bash-4.2$
-bash-4.2$

Popular Posts