CentOS에서 mysql root 비밀번호를 잃어버릴때가 있습니다. 그럴 경우 일반적으로 mysqld_safe 명령어를 이용하여 root 비밀번호를 변경합니다. 그러나 상위버전의 mysql의 경우 mysqld_safe 파일이 없습니다. 그러므로 mysqld_safe 명령이 존재하지 않을 때 root 비밀번호를 변경하는 방법에 대해서 알아보겠습니다.
2. mysqld 서버를 중지합니다.
[root@localhost /] systemctl stop mysqld
3. mysql 서버에 –skip-grant-tables 옵션을 설정해 줍니다.
[root@localhost /] systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
4. mysqld 서버를 시작합니다.
[root@localhost /] systemctl start mysqld
5. root 사용자로 mysql 서버에 접속을 합니다.
[root@localhost /] mysql
6. root 비밀번호를 변경합니다. flush 적용
mysql> update user set authentication_string=PASSWORD('비밀번호') where user='root';
mysql> flush privileges;
7. mysql 접속을 빠져나온 후 mysqld 서버를 중지합니다.
[root@localhost /] systemctl stop mysqld
8. mysql 서버에 unset-environment MYSQLD_OPTS 옵션을 설정해 줍니다.
[root@localhost /] systemctl unset-environment MYSQLD_OPTS
9. mysqld 서버를 시작합니다.
[root@localhost /] systemctl start mysqld
[MYSQL] 벌크 insert 대량 데이터 삽입하기 (0) | 2022.02.14 |
---|---|
[sql] MYSQL 번호 부여하기 @ROWNUM (0) | 2022.02.11 |
mysql 계정 생성하고 권한 부여 (0) | 2021.11.01 |
[DB] mariadb 한글 깨짐 인코팅 설정 utf8 (0) | 2021.10.19 |
mariadb root 비빌번호 설정 (0) | 2021.09.28 |
댓글 영역