- (참고) 사용자 추가 방법 , ex) user2
> INSERT INTO `mysql`.`user` (`Host`, `User`, `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv`, `Create_view_priv`, `Show_view_priv`, `Create_routine_priv`, `Alter_routine_priv`, `Create_user_priv`, `Event_priv`, `Trigger_priv`, `Create_tablespace_priv`, `ssl_type`, `ssl_cipher`, `x509_issuer`, `x509_subject`, `max_questions`, `max_updates`, `max_connections`, `max_user_connections`, `plugin`, `authentication_string`, `password_expired`, `password_last_changed`, `password_lifetime`, `account_locked`, `Create_role_priv`, `Drop_role_priv`, `Password_reuse_history`, `Password_reuse_time`, `Password_require_current`, `User_attributes`) VALUES ('localhost', 'user2', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'Y', 'N', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', '', '', '', '', 0, 0, 0, 0, 'mysql_native_password', '', 'N', '2021-12-09 05:22:18', NULL, 'N', 'Y', 'Y', NULL, NULL, NULL, NULL);

> FLUSH PRIVILEGES;

 


//-------------------------------------
    - 비밀번호 설정
> SET PASSWORD FOR 'user2'@'localhost' = '새비밀번호';
        - PASSWORD() 함수 필요없음
        - FLUSH PRIVILEGES; 필요없음

 


    - 참고! 다음은 에러 발생
> UPDATE mysql.user SET authentication_string = PASSWORD('새비밀번호') WHERE User = 'user2' AND Host = 'localhost';

 

//-------------------------------------
    - DB 접속 확인
> mysql -h localhost --port 3306 -u user2 -p비밀번호

 

반응형
Posted by codens