MySQL -> MariaDB로 마이그레이션 하는 중

계정정보를 따로 추출하는 걸 발견해서

따로 기록해둔다.

나중에 유용할듯?!

mysql -u유저 -p`비밀번호` -e"select concat('show grants for ','\'',user,'\'@\'',host,'\'') from mysql.user" > user_list_with_header.txt
sed '1d' user_list_with_header.txt > ./user.txt
while read user; do
    mysql -u유저 -p`비밀번호` -e"$user" > user_grant.txt
    sed '1d' user_grant.txt >> user_privileges.txt
    echo "flush privileges" >> user_privileges.txt
done <user.txt
awk '{print $0";"}' user_privileges.txt >user_privileges_final.sql
rm user.txt user_list_with_header.txt user_grant.txt user_privileges.txt

발견지: https://stackoverflow.com/questions/23519797/how-to-export-import-existing-user-with-its-privileges?noredirect=1&lq=1 

To be continued.........

 

 

Made by 꿩

'Database > RDBMS' 카테고리의 다른 글

[MySQL/MariaDB] my.cnf 메모리 설정  (0) 2022.06.11
[PostgreSQL] Architecture  (0) 2022.03.01
[MariaDB] mariabackup 백업 & 복구  (0) 2022.02.15
Transaction과 Isolation Level  (0) 2021.04.07
MVCC 동시성 제어  (0) 2021.02.06

+ Recent posts