Installasi MySQL, PostgreSQL dan Oracle pada OS Ubuntu 18.04

Selamat datang di blog saya yang sederhana ini, kali ini saya dapat tugas dari dosen 😁 untuk melakukan installasi beberapa aplikasi database berbasis SQL. Pertama, kenapa SQL? Hingga saat ini database berbasis SQL masih sering digunakan, dan bahkan masih sangat populer sampai saat ini. Lihat gambar dibawah, statistik popularitas database pada tahun sebelumnya, SQL sangat mendominasi.

Popularitas DB di Tahun 2019
Kenapa SQL sangat populer? padahal masyarakat IT saat ini sedang hype sama NoSQL... Menurut saya pribadi, Pertama, SQL didukung oleh banyak sistem operasi dan bahasa pemrograman, Kedua, kebanyakan masyarakat sudah terbiasa dengan SQL karena database ini sudah lahir sejak 1995. Ketiga, karena sudah lahir sejak jaman saya belum lahir, otomatis tutorial di internet sangat banyak dengan komunitas yang sangat luas. Sekarang kita mulai saja tahap installasinya.

Spesifikasi

Komputer yang saya gunakan disini menggunakan sistem operasi Ubuntu 18.04. Pengguna Distro Debian based bisa juga mengikuti tutorial ini.

Installasi MySQL

*Sebenarnya sudah saya tulis dibeberapa tutorial sebelumnya, tapi saya jadikan satu saja disini.
**Biasanya jadi MariaDB, tapi basisnya sama saja.

Yang harus dilakukan pertama yaitu melakukan update repository lalu memasang paket MySQL.
sudo apt update
sudo apt install mysql-server
Biasanya, setelah installasi kalian akan di alihakan ke menu secure installation untuk memberikan password root, drop database test, dll. Jika tidak jalankan perintah berikut ini.
sudo mysql_secure_installation 
Outputnya seperti ini :
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] n
 ... skipping.

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
Disini saya tidak memberikan root password, jika kalian mau tinggal ketik "Y" saja, lalu masukkan password kalian.
***Tuh kan jadi MariaDB 😃

Setelah itu jalankan MySQL servicenya.
sudo systemctl start mysql.service
Perintah diatas hanya akan mengaktifkannya sekali saja. Jadi setelah komputer kalian mati, service akan mati juga, dan harus mengaktifkannya lagi saat komputer booting. Jika ingin service dijalankan saat booting secara otomatis, jalankan perintah berikut.
sudo systemctl enable mysql.service
Cek statusnya dulu, apakah service sudah berjalan. Jika statusnya active berarti aplikasi sudah siap digunakan.
sudo systemctl status mysql.service
● mariadb.service - MariaDB 10.1.44 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendo
   Active: active (running) since Thu 2020-03-19 11:01:10 WIB; 4h 25mi
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 858 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 28 (limit: 4915)
   CGroup: /system.slice/mariadb.service
           └─858 /usr/sbin/mysqld
Testing. Masuk ke MySQL console.
mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 39
Server version: 10.1.44-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
Selamat... MySQL berhasil dipasang di komputer kalian.

Installasi PostgreSQL

Hampir sama seperti MySQL tadi. Kita akan melakukan update repository terlebih dahulu. Lalu install paketnya.
sudo apt update
sudo apt install postgresql postgresql-contrib
Setelah installasi selesai, aktifkan service PostgreSQL nya.
sudo systemctl start postgresql
atau
sudo systemctl enable postgresql
Cek statusnya dulu, apakah service sudah berjalan.
sudo systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; ve
   Active: active (exited) since Thu 2020-03-19 15:24:09 WIB; 8min ago
 Main PID: 17055 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/postgresql.service
Setelah sudah dipastikan bahwa service sudah aktif maka, langsung saja kita test, masukkan perintah berikut untuk masuk menu root dari PostgreSQL.
sudo su postgres
* lalu ketikkan perintah psql

postgres@illness:/home/mental$ psql
psql (10.12 (Ubuntu 10.12-0ubuntu0.18.04.1))
Type "help" for help.

postgres=# 
Maka console root PostgreSQL sudah terbuka. Ini menandakan proses installasi sudah berhasil.

Installasi Oracle

Ini aplikasi yang kurang populer menurut saya, karena bersifat close source dan biasanya hanya digunakan oleh perusahaan - perusahaan besar. Langsung saja menuju tutorial installasinya.

Dikarenakan tidak ada versi untuk Linux DEB, download Oracle SQL Developer versi Linux RPM. Extension RPM ini nantinya diconvert menjadi DEB dengan bantuan “Alien”. Alien? Ya “Alien”. Openjdk dan Openjfx juga dibutuhkan untuk menjalankan aplikasi ini. Menurut saya dari ke 3 aplikasi ini, Oracle ini yang installasi nya paling ribet 😂
sudo apt install alien openjdk-8-jdk openjfx
Jangan lupa download file installer Oracle Di Website resminya https://www.oracle.com/tools/downloads/sqldev-v192-downloads.html pilih yang Linux RPM. Kalian harus punya akun Oracle dulu, jadi harus daftar terlebih dahulu untuk mengunduh file ini.
Website Resmi Oracle

Berikutnya, setelah file sudah selesai di unduh, kita akan melakukan konversi dari format RMP ke format DEB. Dengan Alien yang sudah kita install tadi. Buka direktori unduhan kalian, lalu jalankan perintah berikut.
cd ~/Downloads
sudo alien sqldeveloper-*.noarch.rpm
Setelah konversi berhasil, install paket .deb tadi.
sudo apt install ./sqldeveloper_*.deb
Jalankan aplikasi Oracle SQL Developer dari CLI. Cukup ketik sqldeveloper.
sqldeveloper

Jika terjadi error seperti ini.
 Oracle SQL Developer
 Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.

Default JDK not found
Type the full pathname of a JDK installation (or Ctrl-C to quit), the path will be stored in /home/mental/.sqldeveloper/19.2.1/product.conf
Edit file berikut.
nano .sqldeveloper/19.2.1/product.conf
Cari SetJavaHome, uncomment (hapus tanda #), lalu berikan PATH openJDK yang sudah kalian install sebelumnya.
...
SetJavaHome /usr/lib/jvm/java-8-openjdk-amd64/
...
Lalu jalankan lagi perintah sqldeveloper.

Hasilnya :
Loading awal Oracle SQL Developer


Menu utama Oracle

Dengan ini installasi Oracle sudah selesai.


Sumber :


Berikut panduan installasi dari saya, semoga lengkap dan bermanfaat. Jika ada pertanyaan isi dikolom komentar. Terimakasih...

Tidak ada komentar:

Posting Komentar