Database

Database. 1일차 - MySQL User 데이터 관리하기

머용? 2024. 1. 24. 18:48

MySQL user 데이터 관리하기

유저 데이터를 테이블에 삽입하고 지우는 절차에 대해서 알아보자.

  1. 루트권한을 가진 유저로 로그인

    mysql -u root -p
  2. mysql 유저 확인

    USE mysql;
    select * from user;
  3. mysql 유저 생성

    use mysql;
    create user 'username'@'localhost' identified by 'user_password'
  4. 사용자 비밀번호 변경

    set password for 'username'@'localhost';
  5. 권한 부여

    grant all privileges on *.* to 'username'@'localhost';

    -> 로컬호스트 경로의 username이라는 유저에 .(전체권한)을 부여하겠다.

    flush privileges; # 변경된 권한을 적용
    show grants for 'username'@'localhost'; #부여된 권한을 확인
    show grants; # 현재 로그인한 유저의 권한을 확인
  6. 사용자 삭제

    use mysql;
    drop user 'username'@'%';