반응형

MySQL 3.2 에서 MySQL5.6으로 올라오면서 바뀐것 중 하나가 password 함수이다.

즉, password 함수의 구현 알고리즘이 달라져서 암호화 된 내용이 달라졌다.


그러다 보니 해당 password 함수를 사용하는 것들이 바뀌어서 접속이 안되는 현상이 발생한다.


그래서 기존 password 함수를 사용하고자 한다면 old_password 를 설정하면 된다.


vi /etc/my.cnf


아래 내용을 추가해 주자.


[Client]

secure_auth=0


[mysqld]

old_passwords=1

secure_auth=0


이후, DB를 재기동한 후 아래 명령어를 한번 더 확인해 보자


mysql> set old_passwords = 1;

Query OK, 0 rows affected (0.00 sec)


Plugin도 mysql_old_password로 변경하자.

mysql> update user set plugin = 'mysql_old_password';


이제 한번 제대로 변경 되었는지 확인해 보자.

mysql> show variables like 'old_passwords';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| old_passwords | 1     |
+---------------+-------+

mysql> select password('비밀번호');
+--------------------------+
| password('비밀번호') |
+--------------------------+
| 019026871ad12fba         |
+--------------------------+
1 row in set (0.00 sec)

mysql> select old_password('비밀번호');
+------------------------------+
| old_password('비밀번호') |
+------------------------------+
| 019026871ad12fba             |
+------------------------------+
1 row in set, 1 warning (0.00 sec)

Warning (Code 1287): 'OLD_PASSWORD' is deprecated and will be removed in a future release. Please use PASSWORD instead

정상적으로 옛날 암호화를 이용하여 바뀐 것을 확인할 수있다.


하지만 이후에 3버전과 같이 ID 생성 및 권한을 부여해 봤는데...
에러가 발생한다.

내가 테스트해 본 것을 대충 정리해 보면 아래와 같다.
도무지 생성이 되지 않는 것을 확인 할 수 있다...OTL

mysql> grant all privileges on *.* to 아이디@localhost identified by '비밀번호' with grant option;
ERROR 1827 (HY000): The password hash doesn't have the expected format. Check if the correct password algorithm is being used with the PASSWORD() function.

mysql> set password for 아이디@localhost = password ('비밀번호');
ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number

mysql> set password for 아이디@localhost = old_passwords('비밀번호');
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 'old_passwords('비밀번호')' at line 1



결국 이것 저것 해보다 해답을 찾았다.

아래와 같이 진행하면 정상적으로 생성 및 접속이 가능한 것을 확인할 수 있다.


1. create user 'user'@'%';

2. GRANT ALL PRIVILEGES ON *.* TO 'user'@'%';

3. select password('비번') 결과 복사

4.  update mysql.user set password= '복사한 비번 암호화' where user='user' and host = '%';

5. update mysql.user set plugin = 'mysql_old_password' where user='user' and host = '%';

6. flush privileges;

7. 재접속 확인

mysql> grant all privileges on *.* to '아이디'@'localhost';

Query OK, 0 rows affected (0.00 sec)


mysql> select password('비밀번호');

+--------------------------+

| password('비밀번호') |

+--------------------------+

| 019026871ad12fba         |

+--------------------------+

1 row in set (0.00 sec)


mysql> update mysql.user set password = '019026871ad12fba' where user='아이디';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0




*************************** 8. row ***************************

                  Host: localhost

                  User: 아이디

              Password: 019026871ad12fba

           Select_priv: Y

           Insert_priv: Y

           Update_priv: Y

           Delete_priv: Y

           Create_priv: Y

             Drop_priv: Y

           Reload_priv: Y

         Shutdown_priv: Y

          Process_priv: Y

             File_priv: Y

            Grant_priv: N

       References_priv: Y

            Index_priv: Y

            Alter_priv: Y

          Show_db_priv: Y

            Super_priv: Y

 Create_tmp_table_priv: Y

      Lock_tables_priv: Y

          Execute_priv: Y

       Repl_slave_priv: Y

      Repl_client_priv: Y

      Create_view_priv: Y

        Show_view_priv: Y

   Create_routine_priv: Y

    Alter_routine_priv: Y

      Create_user_priv: Y

            Event_priv: Y

          Trigger_priv: Y

Create_tablespace_priv: Y

              ssl_type:

            ssl_cipher:

           x509_issuer:

          x509_subject:

         max_questions: 0

           max_updates: 0

       max_connections: 0

  max_user_connections: 0

                plugin: mysql_native_password    <---해당 plugin도 update로 변경하자.

 authentication_string:

      password_expired: N

8 rows in set (0.00 sec)




mysql> update mysql.user set plugin = 'mysql_old_password' where user='아이디';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0


이후 접속하면 정상적으로 접속 되는 것을 확인할 수 있다.


더 좋은 해결방안이 있으면 알려주세요.ㅠ

반응형

+ Recent posts