Postingan

Menampilkan postingan dengan label MySQL

🔐 How to Connect to Amazon RDS MySQL with IAM Authentication

Amazon RDS supports IAM-based authentication for MySQL. This means you no longer need to hardcode passwords in your code or scripts — instead, you generate a temporary IAM token securely. But setting it up can get tricky. In this guide, you’ll learn: ✅ How to configure IAM auth for MySQL ✅ How to grant user access ✅ How to import a .sql file securely ✅ How to fix common errors like ERROR 1045 and plugin not enabled ✅ Step 1: Enable IAM DB Authentication on Your RDS Instance Go to RDS Console > Your DB > Modify Scroll to "IAM DB Authentication" Set to ✅ Enabled Apply changes ( Apply immediately ) This allows your MySQL instance to accept login using IAM tokens. ✅ Step 2: Create a MySQL User with IAM Plugin Connect using the master user : mysql -h <rds-endpoint> -u <master-user> -p Create a new user (e.g. wordpress_db_user ) with IAM support: CREATE USER 'wordpress_db_user'@'%' IDENTIFIED WITH AWSAuthenticationPl...

Configure SSH tunnel MySQL

Pada postingan ini sederhana sebagai catatan yaitu akan seolah-olah mengakses database pada server melalui local-pc. local-pc -----------internet----------------server-db server-db dengan IP misal 1.2.3.4 Daripada mengakses langsung database melalui IP publik internet yang tidak aman maka lebih baik memanfaatkan protokol SSH yang terenkripsi. command nya sederhana yaitu sebagai berikut: ssh nasohi@1.2.3.4  -L 3306:localhost:3306 S etelah berhasil masuk, bisa buka terminal lain/aplikasi database client untuk mengakses database melalu i localhost:3306 pada local-pc SSH tunnel ini bisa dimanfaatkan tidak hanya untuk remote database namun bisa disesuaikan dengan port service lainnya. Referensi lebih lanjut:  https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding Postingan di blog ini tentang mysql  https://nciptandani.blogspot.com/search?q=mysql

Cara install MariaDB di Debian 9

Untuk install software database MariaDB cukup mudah, berikut langkah-langkahnya: Update debian #apt-get update Install paket software MariaDB #apt-get install mariadb-server Enable mysql_native_password plugin #mysql -u root USE mysql; UPDATE user SET plugin='mysql_native_password' WHERE User='root'; FLUSH PRIVILEGES; exit systemctl restart mysql.service Initial setting MariaDB #mysql_secure_installation Ikuti hal-hal yang perlu disetting Setelah selesai MariaDB siap digunakan.

How to check MySQL Database size in Linux

SELECT table_schema "DB Name",         ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"  FROM information_schema.tables  GROUP BY table_schema; or #du -h /var/lib/mysql

SQLSTATE[42000]: Syntax error or access violation: 1115 Unknown character set: 'utf8mb4'

Error: SQLSTATE[42000]: Syntax error or access violation: 1115 Unknown character set: 'utf8mb4' Solution: Go to config/database.php and replace these two lines with these 'charset' => 'utf8',  'collation' => 'utf8_unicode_ci',

GRANT ACCESS TO A DATABASE FROM REMOTE

Edit my.cnf Supaya database server bisa diremote dari pc lain, beri tanda pagar pada script: #skip-networking dan edit bind-address=YOUR-SERVER-IP Buatlah sebuah database itnsa untuk competitior1 dengan password: Skill39 diakses dari IP 1.2.3.4 : Jawab: mysql> CREATE DATABASE itnsa; mysql> GRANT ALL ON itnsa.* TO competitor1@'1.2.3.4' IDENTIFIED BY 'Skill39'; Tambahan Cara edit mysql> use mysql; mysql> update db set Host='1.2.3.5' where Db='itnsa'; mysql> update user set Host='1.2.3.5' where user='competitor1'; mysql> update user set password=PASSWORD("NEWPASSWORD") where user='it1'; mysql> flush privileges; Cara akses #mysql -u root -h YOUR-SERVER-IP -p

Cara import dan export database via command line di MySQL

Cara export: mysqldump -u username -p database_name > data-dump.sql Cara import: mysql -u root -p CREATE DATABASE new_database; mysql -u username -p new_database < data-dump.sql

Create mysql user and privileges

Soal: Login sebagai root, buatlah database dengan nama skill39 kemudian buatlah sebuah user mysql dengan nama: dbadm1, password: admp4sswd dan berikan akses hanya ke database skill39, user tersebut hanya bisa mengakses dari localhost, gunakan ssh tunnel jika ingin mengakses database secara remote. Jawab: mysql -u root -p mysql> create database skill39; mysql> CREATE USER 'dbadm1'@'localhost' IDENTIFIED BY 'admp4sswd'; mysql> GRANT ALL PRIVILEGES ON skill39.* TO 'dbadm1'@'localhost'; mysql> flush privileges;

Cara reset password MySQL

if you really forget what your mysql root password, this is just 6 easy steps to reset the password of your mysql. 1. Stop MySQL service #/etc/init.d/msql  stop 2. Start MySQL safe mode #mysqld_safe --skip-grant-tables  & Output : [1] 5988 Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[6025]: started Press anykey 3. Connect to mysql server using mysql client: #mysql -u root Now you are not asked to enter a password Output : Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>