MySQL 5.7 초기 비밀번호 변경 오류 해결 방법
MySQL 5.7.19 이후 버전을 설치한 후 로그인하면 다음과 같은 오류가 발생할 수 있습니다.
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
이 오류는 MySQL 보안 정책에 따라 초기 비밀번호를 반드시 변경해야 하기 때문에 발생합니다.
초기 비밀번호를 변경하기 전에는 SHOW DATABASES와 같은 일반 SQL 명령을 실행할 수 없습니다.
1. MySQL 접속
MySQL에 root 계정으로 접속합니다.
./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.19
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
2. 명령 실행 시 발생하는 오류
비밀번호를 변경하기 전에 SQL 명령을 실행하면 오류가 발생합니다.
show databases;
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
3. 비밀번호 변경
다음 명령을 사용하여 root 계정의 비밀번호를 변경합니다.
SET PASSWORD = PASSWORD('P@ssw0rd1!');
mysql> SET PASSWORD = PASSWORD('P@ssw0rd1!');
Query OK, 0 rows affected, 1 warning (0.01 sec)
4. 정상 동작 확인
비밀번호 변경 후 SQL 명령이 정상적으로 실행됩니다.
select 1;
mysql> select 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
권한 정보를 갱합니다.
FLUSH privileges;
mysql> FLUSH privileges;
Query OK, 0 rows affected (0.00 sec)
5. 데이터베이스 목록 확인
이제 데이터베이스 목록을 정상적으로 확인할 수 있습니다.
show databases;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
6. MySQL 종료
exit
mysql> exit
Bye
MySQL 5.7 이후 버전에서는 보안 정책에 따라 초기 비밀번호 변경이 필수입니다.
'리눅스' 카테고리의 다른 글
| [draft] smem 명령어 (0) | 2026.03.07 |
|---|---|
| [draft] Docker Compose 리소스 제약 조건 구성 (0) | 2026.03.07 |
| [draft] docker compose ls 명령어 (0) | 2026.03.07 |
| [draft] Docker 데몬 소켓 연결 권한 오류 해결 (0) | 2026.03.07 |
| [draft] 도커 컨테이너 재시작 정책 사용 (0) | 2026.03.07 |