WSL2 에서 MySql root 계정으로 remote, localhost 모두 접속 하기
2022. 1. 5. 16:43ㆍWSL2
반응형
WSL2 에 mysql 을 깔고
localhost 및 remote 주소로 접근하는 방법
remote 주소로 접근
use mysql;
1. remote 계정 만들기 ('%')
CREATE USER 'root'@'%' IDENTIFIED BY '비밀번호';
2. 권한 주기
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '비밀번호';
flush privileges;
3. 확인
select user, host, plugin, authentication_string from user;
4. /etc/mysql/mysql.conf.d/mysqld.cnf 에 아래와 같이 변경
#bind-address = 127.0.0.1
[mysqld]
bind-address = 0.0.0.0
localhost 로 접근하게 하기
1. 아래 명령 실행
use mysql;
select user, host, plugin, authentication_string from user;
만약 root@localhost 의 plugin 이 auth_socket 으로 되어 있다면
2. password 형태 변경
update user set plugin='mysql_native_password' where user='root' and host='localhost';
flush privileges;
3. 확인
select user, host, plugin from user;
4. mysql service restart
sudo service mysql restart;
반응형
'WSL2' 카테고리의 다른 글
Docker client 를 이용한 Windows 에서 docker 사용 (0) | 2023.08.21 |
---|---|
Windows 에서 WSL2 에 Docker Desktop 없이 docker 설치 (0) | 2023.04.17 |
Docker 설치 (Without Docker Desktop) (0) | 2022.11.29 |
Ubuntu mysql service 자동시작 (0) | 2022.01.19 |