Cara Install MariaDB Di Ubuntu 22.04 LTS Server
Di artikel ini saya akan menjelaskan tentang cara install mariadb di ubuntu 22.04 lts server. MariaDB merupakan database server yang banyak digunakan oleh banyak penyedia web hosting. Bahkan beberapa perusahaan besar banyak yang menggunakan MariaDB seperti google, amazon, tumblr, wikipedia dan masih banyak lainnya. Bagi anda para blogger yang menggunakan wordpress, anda bisa menggunakan mariadb sebagai database server untuk menyimpan data blog anda.
Bagi para pengguna ubuntu 22.04 lts server, sebelum menginstall MariaDB di ubuntu 22.04 lts server anda harus memastikan bawah hosting server anda memiliki spesifikasi sebagai berikut.
- Ram minimal 512 Megabyte.
- Memiliki akses root atau user yang memiliki akses privilege sebagai root.
- Memiliki ruang penyimpanan yang cukup, bisa harddisk atau ssd.
Jika spesifikasi ubuntu 22.04 lts server yang anda sewa seperti tersebut di atas, anda bisa menginstall MariaDB di web hosting server tersebut. Berikut ini langkah-langkah untuk menginstall MariaDB di ubuntu 22.04 lts server.
1. Login ke web hosting vps anda.
ssh -i opensshkey root@ip-server
2. Update ubuntu 22.04 lts server. Untuk mengupdate ubuntu 22.04 lts server, ketikkan baris perintah berikut di bawah ini. Kemudian tekan enter.
apt update
3. Install mariadb. Untuk menginstall mariadb, ketikkan baris perintah berikut di bawah ini. Kemudian tekan enter.
apt install mariadb-server
4. Jalankan security script mariadb. Security script berfungsi untuk menseting agar mariadb yang anda install berjalan lancar dan aman. Untuk menjalankan security script, ketikkan baris perintah berikut di bawah ini. Kemudian tekan enter.
mysql_secure_installation
Ketika anda menjalankan security script mariadb, akan muncul beberapa opsi pilihan yang berhubungan dengan aplikasi mariadb yang barusan anda install.
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
haven't set the root password yet, you should just press enter here.
Untuk opsi pilihan di atas tersebut, tekan enter. Opsi berikutnya adalah sebagai berikut.
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Untuk opsi pilihan di atas tersebut, anda disarankan untuk menjawab 'n' kemudian tekan enter. Opsi berikutnya adalah sebagai berikut.
Switch to unix_socket authentication [Y/n]
... skipping.
You already have your root account protected, so you can safely answer 'n'.
Untuk opsi pilihan di atas tersebut, anda disarankan untuk menjawab 'n' kemudian tekan enter. Opsi berikutnya adalah sebagai berikut.
... 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]
Untuk opsi pilihan di atas tersebut, anda disarankan untuk menjawab 'Y' kemudian tekan enter. Opsi berikutnya adalah sebagai berikut.
... 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]
Untuk opsi pilihan di atas tersebut, anda disarankan untuk menjawab 'Y' kemudian tekan enter. Opsi berikutnya adalah sebagai berikut.
... Success!
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]
Untuk opsi pilihan di atas tersebut, anda disarankan untuk menjawab 'Y' kemudian tekan enter. Opsi berikutnya adalah sebagai berikut.
- 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]
Untuk opsi pilihan di atas tersebut, anda disarankan untuk menjawab 'Y' kemudian tekan enter.
... 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!
Sampai tahap ini anda telah berhasil menginstall mariadb di ubuntu 22.04 lts server. Sekarang anda dapat menjalankan mariadb dengan mengetikkan baris perintah berikut, kemudian tekan enter.
systemctl start mariadb
5. Enable mariadb. Agar maridb tetap berjalan walaupun hosting server direstart, anda harus mengenable mariadb.
systemctl enable mariadb
Contoh Setting Mariadb Yang Digunakan Di Website Atau Blog Online
Sebelumnya telah dibahas tentang bagainama cara setting mariadb database server untuk digunakan menyimpan data blog atau website yang dapat diakses secara online. Anda bisa menyimpan data blog anda seperti wordpress, joomla, drupal, dan lain sebagainya. Berikut ini secara lengkap beberapa tahapan contoh setting mariadb yang digunakan secara online.
Pertama-tama jalankan security script.
mysql_secure_installation
Selanjutnya anda dapat gunakan berikut contoh setting mariadb yang diguanakan secara online.
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
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] n
... skipping.
You already have your root account protected, so you can safely answer 'n'.
Change the 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] y
... Success!
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!
Cara Login Ke MariaDB
1. Pertama-tama cek terlebih dahulu apakah mariadb sudah berjalan.
systemcl status mariadb
Berikut ini tampilan layar jika mariadb sudah berjalan.
● mariadb.service - MariaDB 10.6.16 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2024-02-02 08:07:30 UTC; 1h 3min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
2. Untuk login ke MariaDB, ketikkan baris perintah berikut di bawah ini. Kemudian tekan enter.
mariadb
Jika anda berhasil login ke mariadb, tampilan layar anda akan muncul seperti berikut di bawah ini.
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 37
Server version: 10.6.16-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.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)]>
Jika tampilan layar anda seperti tersebut di atas, maka anda berhasil login ke mariadb.
3. Selanjutnya anda perlu mengecek semua database yang secara default bawaan dari mariadb.
show databases;
Berikut tampilan layar semua database bawaan dari mariadb.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.001 sec)
Sintak Dasar Menjalankan MariaDB
Berikut ini beberapa sintak dasar mariadb yang perlu anda tahu.
1. Sintak untuk menjalankan mariadb.
systemctl start mariadb
2. Sintak untuk enable mariadb.
systemctl enable mariadb
3. Sintak untuk restart mariadb.
systemctl restart mariadb
4. Sintak untuk melihat status mariadb.
systemctl status mariadb
5. Sintak untuk menghentikan mariadb.
systemctl stop mariadb
Demikian artikel tutorial tentang cara install mariadb di ubuntu 22.04 lts server. Sekarang anda dapat membuat database dan menyimpan data di mariadb.
Tags :