Database

[MYSQL]사용자 계정생성

애플자라 2016. 11. 11. 19:39
반응형

[5.7 이전 버젼]
update mysql.user set password=password('새로운패스워드') where user='root';
FLUSH PRIVILEGES;

[5.7 이후 버젼]
update user set authentication_string=password('새로운패스워드') where user='root';
FLUSH PRIVILEGES;

(5.7 이후 버젼에는 password 필드가 존재하지 않는다.)
설정 후 MySQL 접속 후 명령을 실행하게 되면 다음과 같은 장애가 발생한다.

mysql> SELECT 1;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

위와 같은 오류가 발생하는 경우 다음과 같은 명령어를 실행한다.

mysql> SET PASSWORD = PASSWORD('새로운패스워드');
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT 1;
+---+
| 1 |
+---+
| 1 |

 

반응형