database

mysql 8.x 사용자 추가

탄생 2019. 5. 16. 16:17

mysql 을 8.x으로 사용자를 접속하면 아래와 같은 에러가 발생을 한다.

client does not support authentication protocol requested by server consider upgrading mysql client

 

mysql 8.0부터 암호화의 기본 인증 플러그인을 caching_sha2_password 을 사용하여 기존보다 안전한 암호화를 제공한다.

옛날의 mysql client는 아직 해당 암호 플러그인을 인식하지 못하는 문제가 발생하므로 이전의 암호 플러그인으로 변경하여 암호를 저장해 줍니다.

https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password

 

// 사용자 정보 조회 
SELECT user,authentication_string,plugin,host FROM mysql.user; 

// 사용자 생성 
create user 'root'@'localhost' identified by 'pass'; 

// 권한 부여 
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'; 
GRANT GRANT OPTION ON *.* TO 'root'@'localhost'; 

// 비밀번호 plugin 변경 
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'pass';