Database/MySQL

[MySQL] MySQL 비밀번호 변경 방법

Junhong Kim 2018. 3. 29. 12:23
728x90
반응형

MySQL 비밀번호 변경

(1) MySQL 실행

$ mysql -u root -p
Enter password:

(2) 비밀번호 변경을 위해 mysql 데이터베이스 사용

mysql> use mysql;
Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed

(3) 현재 암호 확인

// mysql 5.x 는 "password" 또는 "authentication_string"로 확인합니다.
mysql> select host, user, password from user;
mysql> select host, user, authentication_string from user;

// mysql 8.x
mysql> select host, user, authentication_string from user;

(4) 비밀번호 변경

root 계정의 비밀번호를 1234로 변경

// mysql 5.x
mysql> update user set password=password('1234') where user='root';
mysql> update user set authentication_string=password('1234') where user='root';

// mysql 8.x
mysql> alter user 'root'@'localhost' identified with mysql_native_password by '1234';

(5) 종료

변경사항을 적용하기 위해 아래 명령어를 실행한 후 종료하면 비밀번호 변경이 완료됩니다.

mysql> flush privileges;
mysql> quit Bye

 

 

728x90
반응형