MySQL: Buat User dan Database

From Catatan IBM
Jump to navigation Jump to search

Ubuntu 20.04

Masuk ke MySQL

sudo mysql

atau

mysql -u root -p

buat database

CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Buat User

CREATE USER 'db_user'@'%' IDENTIFIED WITH mysql_native_password BY 'password';

Grant

GRANT ALL ON db_name.* TO 'db_user'@'%';

Flush

FLUSH PRIVILEGES;
exit;


Ubuntu 22.04

Masuk ke MySQL

sudo mysql

atau

mysql -u root -p

Buat database

CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Buat User

CREATE USER 'db_user'@'%' IDENTIFIED WITH mysql_native_password BY 'password';

Grant

GRANT ALL ON db_name.* TO 'db_user'@'%';

Flush

FLUSH PRIVILEGES;

exit

exit;