Ganti Password ROOT MariaDB di Ubuntu 22.04 | Change ROOT Password MariaDB On Ubuntu 22.04

[STUDI KASUS LUPA PASSWORD MARIADB PADA SISTEM OPERASI UBUNTU]

[1] Login ke dalam Ubuntu 22.04 melaui SSH

# ssh firman@IPAdrress -p [port SSH]

contoh
# ssh firman@192.168.100.16 -p 22

[2] Pindah dari user $ ke root (#)

$ sudo su
# 

[3] Masuk ke user root MariaDB

# mysql -u root -p
[4] Hilangkan akses/privileges pada user MariaDB agar dapat dimasukkan password yang baru menggunakan command Flush PRIVILEGES;
MariaDB [(none)]> FLUSH PRIVILEGES;

[5] Masukkan password baru pada user root MariaDB menggunakan Command di Bawah ini

MariaDB [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'masukkan_password_baru_di_sini';

[6] Selanjutnya keluar dari aplikasi mariaDB & level account root sampai ke level (standar user/$) lalu test login ke dalam mariaDB menggunakan user root MariaDB dengan command di bawah ini

ubuntu@ubuntu:~$ mariadb -u root -p
Dokumentasi Step 4,5,6
/////////////////////LOGIN KE APLIKASI MARIADB (BY PASS ROOT) ////////////////////////////
root@ubuntu:/home/ubuntu# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 86
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.
/////////////////////BUANG AKSES/PRIVILEGES MARIADB////////////////////////////
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)

/////////////////////UPDATE PASSWORD ROOT BARU MARIADB////////////////////////////
MariaDB [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'masukkan_password_baru_di_sini';
Query OK, 0 rows affected (0.016 sec)

/////////////////////KELUAR DARI APLIKASI MARIADB////////////////////////////
MariaDB [(none)]> exit
Bye
/////////////////////KELUAR DARI USER ROOT KE $ (standar user) ////////////////////////////
root@ubuntu:/home/ubuntu# exit
exit

////////////////////POSISI DI STANDAR USER///////////////////////////////Dokumentasi Step 4,5,6
/////////////////////LOGIN KE APLIKASI MARIADB (BY PASS ROOT) ////////////////////////////
root@ubuntu:/home/ubuntu# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 86
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.
/////////////////////BUANG AKSES/PRIVILEGES MARIADB////////////////////////////
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)

/////////////////////UPDATE PASSWORD ROOT BARU MARIADB////////////////////////////
MariaDB [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'masukkan_password_baru_di_sini';
Query OK, 0 rows affected (0.016 sec)

/////////////////////KELUAR DARI APLIKASI MARIADB////////////////////////////
MariaDB [(none)]> exit
Bye
/////////////////////KELUAR DARI USER ROOT KE $ (standar user) ////////////////////////////
root@ubuntu:/home/ubuntu# exit
exit

////////////////////POSISI DI STANDAR USER///////////////////////////////Dokumentasi Step 4,5,6
/////////////////////LOGIN KE APLIKASI MARIADB (BY PASS ROOT) ////////////////////////////
root@ubuntu:/home/ubuntu# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 86
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.
/////////////////////BUANG AKSES/PRIVILEGES MARIADB////////////////////////////
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)

/////////////////////UPDATE PASSWORD ROOT BARU MARIADB////////////////////////////
MariaDB [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'masukkan_password_baru_di_sini';
Query OK, 0 rows affected (0.016 sec)

/////////////////////KELUAR DARI APLIKASI MARIADB////////////////////////////
MariaDB [(none)]> exit
Bye
/////////////////////KELUAR DARI USER ROOT KE $ (standar user) ////////////////////////////
root@ubuntu:/home/ubuntu# exit
exit

////////////////////POSISI DI STANDAR USER/////////////////////////////////////////////////////
////////////////TEST LOGIN KE MARIADB MENGGUNAKAN USER ROOT MARIADB////////////////////////////
ubuntu@ubuntu:~$ mariadb -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 88
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)]> 
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''masukkan_password_baru_di_sini'' at line 1
MariaDB [(none)]>
////////////////TEST LOGIN KE MARIADB MENGGUNAKAN USER ROOT MARIADB///////////////////////////////
ubuntu@ubuntu:~$ mariadb -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 88
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)]> 
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''masukkan_password_baru_di_sini'' at line 1
MariaDB [(none)]>
////////////////TEST LOGIN KE MARIADB MENGGUNAKAN USER ROOT MARIADB///////////////////////////////
ubuntu@ubuntu:~$ mariadb -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 88
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)]> 
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''masukkan_password_baru_di_sini'' at line 1
MariaDB [(none)]>
Referensi:
https://www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mariadb-root-password