카테고리 없음

[MySQL] 새로운 설정 시 MySQL 캐시 지우기? FLUSH PRIVILEGES

보리시스템 2024. 3. 14.

테이블 내 칼럼 타입 형변환을 해야 하는 상황이 발생해 타입변환 이전에 백업용으로 테이블을 복제해놓았는데 두 테이블 간 용량 차이가 나는 걸 발견했다. (백업용 테이블의 용량이 더 작은 상황)

그 이유는 바로 테이블을 복제할 때 인덱스 등으로 물려 있었던 MySQL 캐시는 날아간채로 복제됐기 때문이라고 한다. 즉 기존의 테이블은 가비지 컬렉션과 같은 데이터를 가지고 있었던 것이다.

사실 DB의 설정을 바꾼다는 것 자체가 자주 있어서는 안되는 일이지만 지금과 같이 어쩌다 어쩔 수 없이 설정 상의 변경이 필요한 경우에는 아래의 명령어를 통해 MySQL 캐시를 지워줘야 한다.

FLUSH PRIVILEGES

 

 

https://stackoverflow.com/questions/36463966/mysql-when-is-flush-privileges-in-mysql-really-needed

 

MySQL: When is Flush Privileges in MySQL really needed?

When creating new tables and a user to go along with it, I usually just invoke the following commands: CREATE DATABASE mydb; GRANT ALL PRIVILEGES ON mydb.* TO myuser@localhost IDENTIFIED BY "

stackoverflow.com

 

https://dev.mysql.com/doc/refman/5.7/en/privilege-changes.html

 

MySQL :: MySQL 5.7 Reference Manual :: 6.2.9 When Privilege Changes Take Effect

6.2.9 When Privilege Changes Take Effect If the mysqld server is started without the --skip-grant-tables option, it reads all grant table contents into memory during its startup sequence. The in-memory tables become effective for access control at that po

dev.mysql.com