728x90
Login MySQL with root account
$ mysql -u root -p
Enter password:
Create a database
mysql> CREATE DATABASE sample;
Query OK, 1 row affected (0.00 sec)
Create users
// For all IPs, use '%'
mysql> CREATE USER 'sample_writer'@'%' identified by 'sample_password';
Query OK, 0 rows affected (0.01 sec)
// For only localhost, use 'localhost' or '127.0.0.1'
mysql> CREATE USER 'sample_writer'@'localhost' identified by 'sample_password';
Query OK, 0 rows affected (0.01 sec)
// I recommend you to make a writer and a reader together
mysql> CREATE USER 'sample_reader'@'%' identified by 'sample_password';
Query OK, 0 rows affected (0.01 sec)
Grant all privileges or read only
// sample.* means all tables in sample database
// If you want to grant a specific table, use sample.specific_table
mysql> GRANT ALL PRIVILEGES ON sample.* to 'sample_writer'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT SELECT ON sample.* to 'sample_reader'@'%';
Query OK, 0 rows affected (0.00 sec)
728x90
'프로그래밍 > DevOps' 카테고리의 다른 글
Create Swap Memory on Amazon Linux (0) | 2023.01.26 |
---|---|
Generate crt and key on Amazon Linux (0) | 2023.01.26 |
Deploy HTTPS Web services on Amazon Linux 2 (0) | 2023.01.26 |
Amazon Linux2 MySQL 8 Setup (0) | 2023.01.25 |
댓글