본문 바로가기
일지

[MySQL] 계정 생성 시 에러 발생

by 닉닉눅 2023. 7. 13.
728x90
반응형

MySQL에서 테스트 계정을 생성하려고 했는데 다음과 같은 에러가 나왔습니다.

mysql> GRANT ALL PRIVILEGES ON *.* to 'test'@'localhost' IDENTIFIED BY 'test123';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'test123'' at line 1

알아보니까 MySQL version 5.7.6. 버전 이후 부터는 GRANT 문과 함께 IDENTIFIED BY 로 계정 생성/ 암호 설정이 사용되지 않습니다.

 

해결방법

1) 유저 생성

mysql> CREATE USER 'test'@'localhost' IDENTIFIED BY 'test123';
Query OK, 0 rows affected (0.12 sec)

2) 권한 부여

mysql> GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost';
Query OK, 0 rows affected (0.03 sec)

계성 생성 겅공
계정 생성 성공!

마지막으로 IDENTIFIED BY '암호'를 사용하는 GRANT는 더 이상 사용되지 않으며 CREATE USER 또는 ALTER USER를 사용하여 사용자 계정을 생성 후 권한을 설정해 줘야합니다.

 

<참고>

https://techglimpse.com/error-grant-identified-by-password/

 

Error using GRANT with IDENTIFIED by password in MySQL - Techglimpse

GRANT with IDENTIFIED by password fails in MySQL? Well, the feature is now deprecated for good reasons and here's an alternate method.

techglimpse.com

 

728x90
반응형

댓글