Monday, February 24, 2020

Cara tambah user baru di mysql dan update privileges

Login sebagai root

mysql -u root -p

Buat username dan password  mysql baru

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'user_password';

Beri privileges ke akun yang dibuat, ada beberapa privileges untuk mysql yaitu:
  • ALL PRIVILEGES – Grants all privileges to a user account.
  • CREATE – The user account is allowed to create databases and tables.
  • DROP - The user account is allowed to drop databases and tables.
  • DELETE - The user account is allowed to delete rows from a specific table.
  • INSERT - The user account is allowed to insert rows into a specific table.
  • SELECT – The user account is allowed to read a database.
  • UPDATE - The user account is allowed to update table rows.

Contoh :

Beri akses ke semua database kepada suatu user :
  • GRANT ALL PRIVILEGES ON *.* TO 'database_user'@'localhost';

Jalankan perintah flush privileges untuk mereload semua permission di mysql

FLUSH PRIVILEGES;
Share:

0 comments:

Post a Comment

This Blog is protected by DMCA.com