인디노트

MySQL root 비밀번호 초기화 본문

개발 플랫폼 및 언어

MySQL root 비밀번호 초기화

인디개발자 2017. 11. 8. 11:22

Mac 환경에서 MySQL 5.7.9 버젼 설치 후 root 접속 시도 시 패스워드 장애로 MySQL 접속이 불가능하다.


#sudo /usr/local/mysql/support-files/mysql.server stop

#sudo mysqld_safe --skip-grant-tables

#mysql -u root

update mysql.user set password=password('2261bbs') where user='root';


콘솔 윈도우에서 mysqld_safe 실행으로 safe 모드로 MySQL 데몬을 구동하고 다른 콘솔 윈도우를 띄어 MySQL에 접속한다.


#mysql -u root


접속 후 다음 명령어로 root 비밀번호를 업데이트한다.


[5.7 이전 버젼]


update mysql.user set password=password('2261bbs') where user='root';

FLUSH PRIVILEGES;

[5.7 이후 버젼]

update user set authentication_string=password('2261bbs') 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('2261bbs');


Query OK, 0 rows affected (0.01 sec)


mysql> SELECT 1;

+---+

| 1 |

+---+

| 1 |



PASSWORD 난이도 설정 my.cnf 에 추가

validate_password_policy=LOW


반응형
Comments