> ALTER USER 'root'@'localhost' IDENTIFIED BY '설정할비밀번호';
Query OK, 0 rows affected (0.00 sec)
// 5.7.6 이전 버전
> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('설정할비밀번호');
버전 확인 방법
> SHOW VARIABLES LIKE "%version%";
+-------------------------+-------------------------+
| Variable_name | Value |
+-------------------------+-------------------------+
| innodb_version | 5.7.31 |
| protocol_version | 10 |
| slave_type_conversions | |
| tls_version | TLSv1,TLSv1.1,TLSv1.2 |
| version | 5.7.31-0ubuntu0.18.04.1 |
| version_comment | (Ubuntu) |
| version_compile_machine | x86_64 |
| version_compile_os | Linux |
+-------------------------+-------------------------+
8 rows in set (0.00 sec)
> SHOW GRANTS FOR '계정명'@'%';
+------------------------------------+
| Grants for 계정명@% |
+------------------------------------+
| GRANT USAGE ON *.* TO '계정명'@'%' |
+------------------------------------+
> GRANT ALL PRIVILEGES ON DB명.* to '계정명'@'%';
Query OK, 0 rows affected (0.00 sec)
> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
> SHOW GRANTS FOR '계정명'@'%';
+--------------------------------------------------+
| Grants for 계정명@% |
+--------------------------------------------------+
| GRANT USAGE ON *.* TO '계정명'@'%' |
| GRANT ALL PRIVILEGES ON `DB명`.* TO '계정명'@'%' |
+--------------------------------------------------+
2 rows in set (0.00 sec)
외부 접속 허용
$ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
(기존) bind-address = 127.0.0.1 // 내부에서만 3306 호출하도록 설정, 아래는 외부에서 인입 가능하도록 설정
(변경) bind-address = 0.0.0.0
$ sudo systemctl restart mysql