Dev/DevOps
[Docker] 사용자 권한에러 MySQL : Access denied for user 'root'@'172.17.0.1'
Fullth
2023. 3. 13. 23:42
환경
NestJS + (Docker) MySQL8 + TypeORM
에러 내용
[Nest] 13641 - 2022. 10. 10. 오후 1:15:23 ERROR [TypeOrmModule] Unable to connect to the database. Retrying
(2)... Error: Access denied for user 'root'@'172.17.0.1' (using password: YES)
상황
TypeORM과 MySQL 연동 중 접근이 거부됨.
해결방법
-- user 필요할 경우 생성한 후 권한 주면 됨.
mysql> CREATE USER 'username'@'172.17.0.1' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON . TO 'username'@'172.17.0.1' WITH GRANT OPTION;
mysql> flush privileges;
mysql> exit;
아래 명령어로 권한 잘 들어갔는지 확인.
use mysql;
SELECT * FROM user;
orm 관련 config 파일과 db관련에 유저 정보 잘 입력했는지 확인.