1. MySQL 설치
참고로 MySQL 5.7.44 버전을 설치했다 삭제하여 재설치했는데, 심각한 오류가 발생하여 PC를 초기화했다.
그 후 MySQL 5.7.43 버전으로 설치 진행했다.
원인은 서버 실행이 되지 않는다는 것이었다.
Log를 분석했는데,
1. MySQL은 설치가 완료되었음
2. 서버 실행이 되지 않음
서버 실행이 되지 않은 원인을 찾아 하나씩 해결했다.
비밀번호를 설정했는데도 설정한 비밀번호가 먹지 않았다.
그래서 비밀번호 재설정이 필요했다.
1. 명령 프롬프트를 관리자 권한으로 실행하여 mysql 실행을 중지했다.
2. mysql이 설치된 디렉터리로 이동 후 mysql을 안전모드로 시작했다.
3. 새 명령 프롬프트 창에서 mysql에 root 사용자로 로그인 후 비밀번호를 재설정했다.
4. 모든 mysql 프로세스를 중지한다.
5. mysql 서버를 정상 모드로 다시 시작한다.
6. 새로운 비밀번호로 mysql에 로그인한다.
1. MySQL 다운로드 페이지 접속
https://downloads.mysql.com/archives/installer/
2. General Availability (GA) Releases - Select Version 설정 - Select Operating System 설정 - Download
'General Availability (GA) Releases'에서
'Select Version'를 '5.7.44'로 설정,
'Select Operating System'을 'Microsoft Windows'로 설정하여
'Windows (x86, 32-bit), MSI Installer' 다운로드 클릭하여 설치한다.
용량이 작은 버전은 웹 버전이므로,
반드시 용량 큰 버전으로 설치하자.
회원 가입하거나 로그인 하라는 화면이 나타날텐데,
'No thanks, just start my download.' 선택해도 다운로드 잘 된다.
3. MySQL 설치 진행
1) Choosing a Setup Type : Full
2) Execute 클릭
하단의 'Execute' 클릭 시 해당 프로그램들이 설치된다.
설치 완료되면 'Next' 클릭
Next 클릭
3) PW 설정
MySQL 서버 비밀번호 설정하기 - Next
Next
Next
Execute
Finish
Next
Finish
Next
PW 입력 (아까 설정한 비밀번호 입력) - Check - Next
Execute
Finish
Next
Finish
▶ MySQL 설치 도중 Apply Configuration - Configuration Steps - Starting the server 에러
위와 같은 에러가 났다.
처음 설치할 땐 막힘없이 잘 설치가 되었는데,
내가 착각하고 모두 삭제하고 재설치를 하는 바람에 무언가 잘못된 것 같았다.
우선 Log 탭을 가서 내용을 확인해보자.
Beginning configuration step: Writing configuration file
Saving my.ini configuration file...
Saved my.ini configuration file.
Ended configuration step: Writing configuration file
Beginning configuration step: Updating Windows Firewall rules
Attempting to delete a Windows Firewall rule with command: netsh.exe advfirewall firewall delete rule name="Port 3306" protocol=TCP localport=3306
규칙을 3개 삭제했습니다.
확인됨
Adding a Windows Firewall rule for MySQL57 on port 3306.
Attempting to add a Windows Firewall rule with command: netsh.exe advfirewall firewall add rule name="Port 3306" protocol=TCP localport=3306 dir=in action=allow
확인됨
Successfully added the Windows Firewall rule.
Ended configuration step: Updating Windows Firewall rules
Beginning configuration step: Adjusting Windows service
Attempting to grant the required filesystem permissions to the 'NT AUTHORITY\NetworkService' account.
Granted permissions to the data directory.
Adding new service
New service added
Ended configuration step: Adjusting Windows service
Beginning configuration step: Updating permissions for the data folder and related server files
Attempting to update the permissions for the data folder and related server files...
Inherited permissions have been converted to explicit permissions.
Full control permissions granted to: NETWORK SERVICE.
Full control permissions granted to: Administrators.
Full control permissions granted to: CREATOR OWNER.
Full control permissions granted to: SYSTEM.
Access to the data directory is removed for the users group.
Permissions for the data folder and related server files are updated correctly.
Ended configuration step: Updating permissions for the data folder and related server files
나의 경우에는 mysql 설치가 되었지만, 서버를 실행하지 못했던 경우이다.
오류 메시지의 내용은 저 내용이 아니라 살짝 달랐던 것 같다.
아래 내용을 포함하고 있던 Log 메시지가 아닐까 추측한다.
Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Connection refused: no further information
Connection refused: no further information
해결 과정은,
아래 파트를 순서대로 참고해주길 바란다.
1) MySQL 삭제
2) 서버와의 통신 링크 실패 오류 메시지
3) MySQL 비밀번호 재설정
포맷은 안했지만 PC 초기화를 해도 재설정 오류가 났던 건에 대하여
정말 알고 지내길 잘한 것 같은 용사 두명의 서포트를 받아 해결할 수 있었다.
아저씨 두명의 앞날을 축복한다.
1. MySQL 삭제
MySQL을 모종의 이유로 삭제하거나 삭제 후 재설치를 희망한다면,
1) 제어판 - 프로그램 제거 - MySQL 관련 프로그램 모두 삭제
2) 폴더 삭제
- C:\Program Files\MySQL
- C:\Program Files (x86)\MySQL
- C:\ProgramData\MySQL
위 경로의 모든 MySQL 폴더를 삭제한다.
참고로 ProgramData 폴더는 숨김 처리 되어 있으니 숨김 파일 보기 한 뒤에 접근하면 된다.
3) 레지스트리 편집기 내 MySQL 관련 폴더 모두 삭제
window + R - regedit - 레지스트리 편집기 실행 - 편집 - 찾기 - 'MySQL' 검색 (문자열 단위로 일치 체크)
MySQL 폴더가 찾아져서 해당 폴더를 삭제하였다.
MySQL 프로그램과 C 드라이브에 있는 MySQL 관련 폴더 모두 삭제했는데도
레지스트리 편집기에 남아있다니 ... 정말 지독한 눔들.
2. 서버와의 통신 링크 실패 오류 메시지
Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Connection refused: no further information
Connection refused: no further information
어디서인지는 가물가물한데....... 하여튼 이런 내용의 메시지를 만난 것 같다.
아마 MySQL 설치 과정에서 Starting the Server의 Log 메시지에 포함된 내용인 것 같다는게 내 추측이다.
아님 말고.
1. 명령 프롬프트 실행 후 3306과 연결된 네트워크 연결 상태 확인
MySQL은 대개 3306 포트를 사용한다. (이는 내 Log 파일에서도 확인 가능하다.)
따라서 현재 MySQL이 3306 포트를 잘 사용하고 있는지 확인할 필요가 있다.
아래의 명령어는 네트워크 연결 상태를 확인하는 netstat 명령어를 사용하여, 포트 3306과 관련된 모든 연결을 표시한다.
C:\Users\sohee>netstat -an | find "3306"
실행 결과를 보면 아무 출력도 없는데, 이는 포트 3306에서 LISTEN 상태인 연결이 없다는 것을 의미한다.
즉, MySQL 서버가 해당 포트에서 실행되고 있지 않다는 것을 나타낸다.
2. MySQL 접속 시도
MySQL 클라이언트를 사용하여 MySQL 서버에 접속 시도를 해보자.
C:\Users\sohee>mysql -u root -p
Enter password: ****
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
오류 메시지가 나타났는데, 이 오류 메시지는 MySQL 서버에 접속할 수 없음을 의미한다.
주로 서버가 실행 중이지 않거나, 방화벽 설정 및 네트워크 문제로 인해 발생하는 오류이다.
3. 서비스 실행
window + R에서 'services.msc' 실행 후 서비스에서 MySQL 서비스 시작됐는지 확인
→ 나의 경우, 실행이 되지 않았다.
4. CMD에서 MySQL 서버 실행 시도
서비스에서 MySQL이 실행 중이지 않아서 cmd를 키고 다음 명령어를 입력했다.
C:\Users\sohee>net start mysql
시스템 오류 5이(가) 생겼습니다.
액세스가 거부되었습니다.
시스템 오류 5 ;
일반적으로 액세스가 거부되었음을 나타내는 오류 코드이다.
이 오류는 주로 다음과 같은 상황에서 발생 가능하다.
1. 권리자 권한 부족
- 프로그램 실행 시 관리자 권한이 필요한 경우.
- 관리자 모드로 실행하지 않으면 이 오류가 발생할 수 있다.
2. 파일 또는 폴더 권한 문제
- 접근하려는 파일이나 폴더에 대한 권한이 부족할 때 발생 가능하다.
3. 네트워크 문제
- 네트워크 상의 리소스에 접근할 때 권한이 없거나 네트워크 설정에 문제가 있을 때 발생 가능하다.
5. MySQL 설정 파일 확인
MySQL 설정 파일(my.ini)에서 bind-address 설정을 확인했다.
기본적으로 bind-address는 127.0.0.1로 설정되어 있어야 한다.
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]
bind-address = 127.0.0.1
server section 밑에 해당 'bind-address = 127.0.0.1' 부분을 수정했거나 추가했던 것 같다.
이 단계까지 완료했더니 서버는 실행이 되는데, 로그인을 하려고 보니 MySQL 비밀번호를 재설정해야 하는 상황이 나타났다.
mysql> mysql -u root -p
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
ERROR:
Can't connect to the server
해당 오류는 MySQL 서버에 접근할 때 비밀번호가 필요하지만 제공되지 않았거나,
잘못된 비밀번호로 인해 접근이 거부되었다는 의미이다.
따라서 MySQL의 root 계정의 비밀번호를 재설정해야 할 필요가 있다.
3. MySQL 비밀번호 재설정
환경 : Window 11, MySQL 5.7
1. 관리자 권한으로 실행한 명령 프롬프트
1. 서비스 관리자에서 MySQL 서비스 중지
2. 관리자 권한으로 명령 프롬프트 실행 후 MySQL이 설치된 디렉터리로 이동하여 다음 명령 입력
mysql이 설치된 경로로 가려면 나의 경우에는 'cd C:\Program Files\MySQL\MySQL Server 5.7'
[MySQL 설치 경로 이동]
C:\Windows\System32>cd C:\Program Files\MySQL\MySQL Server 5.7
[MySQL 설치]
C:\Program Files\MySQL\MySQL Server 5.7>mysqld --install
Service successfully installed.
[MySQL 초기화]
C:\Program Files\MySQL\MySQL Server 5.7>Mysqld --initialize
[MySQL 서비스 실행]
C:\Program Files\MySQL\MySQL Server 5.7>net start mysql
MySQL 서비스를 시작합니다..
MySQL 서비스가 잘 시작되었습니다.
[MySQL 비밀번호 틀림 이슈]
C:\Program Files\MySQL\MySQL Server 5.7>mysql -u root -p
Enter password: ****
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[MySQL 서비스 중단]
C:\Program Files\MySQL\MySQL Server 5.7>net stop mysql
MySQL 서비스를 멈춥니다..
MySQL 서비스를 잘 멈추었습니다.
3. 다음 명령 입력하여 MySQL을 안전 모드로 시작
C:\Program Files\MySQL\MySQL Server 5.7>mysqld --skip-grant-tables
참고로 해당 명령어는 MySQL 서버가 사용자 인증과 권한 검사를 건너뛰고 시작되게 해준다.
이 모드에서는 모든 사용자가 비밀번호 없이 MySQL에 접근 가능하다.
이 명령어는 비밀번호를 재설정하거나 관리 작업을 수행할 때 유용하다.
2. 새 명령 프롬프트 창 실행 (관리자 x)
1. 새 명령 프롬프트 창 실행 - MySQL 접속 (안전 모드)
[MySQL 안전 모드 실행]
C:\Users\sohee>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.43 MySQL Community Server (GPL)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
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.
2. (MySQL 5.7 이상 버전) 비밀번호 재설정 명령어 입력
UPDATE mysql.user SET authentication_string=null WHERE User='root';
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY '새로운비밀번호';
[MySQL User 'root' 설정]
mysql> UPDATE mysql.user SET authentication_string=null WHERE User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
[MySQL에서 사용자 권한 변경 명령어 입력]
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
['root'의 비밀번호 재설정]
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '1234'
-> ;
Query OK, 0 rows affected (0.00 sec)
[MySQL 종료]
mysql> exit
Bye
3. 다시 관리자 권한으로 실행한 명령 프롬프트
1. MySQL 서버를 정상 모드로 다시 시작
C:\Program Files\MySQL\MySQL Server 5.7>net start mysql
MySQL 서비스를 시작합니다..
MySQL 서비스가 잘 시작되었습니다.
4. 다시 명령 프롬프트 창 실행 (관리자 x)
1. 새로운 비밀번호로 MySQL에 로그인하기
C:\Users\sohee>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.43
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
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> exit
Bye
'[Etc]' 카테고리의 다른 글
[Oracle/DBeaver] ORA-12514 (0) | 2024.06.19 |
---|---|
[Error] DBeaver - Can't lock workspace (0) | 2024.06.17 |
[Window] Oracle 12c 설치 (0) | 2024.06.17 |
[윈도우] Apache Tomcat 8.5 설치 (0) | 2024.06.14 |
[Window] PuTTY 설치 (0) | 2024.06.14 |