[WSL] Ubuntu MySQL 설치 및 접속

민수·2022년 12월 21일
0
post-thumbnail

설치

sudo apt update
sudo apt upgrade
sudo apt install mysql-server

설치 후 확인

mysql --version
  • 결과 : mysql Ver 8.0.31-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))

실행 및 확인

sudo service mysql start
ps -ef |grep mysql

netstat -lntup |gerp 3306

초기 설정

sudo mysql_secure_installation

오류

Re-enter new password:
... Failed! Error: SET PASSWORD has no significance for user
'root'@'localhost' as the authentication method used doesn't store authentication 
data in the MySQL server. Please consider using ALTER USER instead if you want to change 
authentication parameters.

New password:

위 에러가 뜨면 터미널을 종료하고 다음 명령어 실행

sudo mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '사용할비밀번호';
mysql> exit

설정 진행

sudo mysql_secure_installation
Enter password for user root:
위에서 설정한 비밀번호 입력
Press y|Y for Yes, any other key for No: n
비밀번호 복잡도 체크 여부
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
root 비밀번호를 변경할 건지

root 비밀번호를 변경하면 다시 오류가 나기때문에 n으로 해줘야함

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
기본적으로 만들어지는 익명 사용자를 삭제할 건지
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
원격에서 root로 접속 차단
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
test db 및 test db 권한 제거
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
권한 테이블을 다시 로드하여 변경 사항 즉시 적용

접속

sudo mysql -u[계정명] -p[비밀번호]
mysql>
mysql> exit

나가기

0개의 댓글