A.19 Restoring Custom MySQL User

Perform the following procedure to restore custom MySQL users:
  1. Log in to the query server as admin user.
  2. Run the following commands on the query server to create a new directory:
    cd /var/TKLC/db/filemgmt
    mkdir user_backup_restore
  3. Download and copy the script to the following path /var/TKLC/db/filemgmt/user_backup_restore.
    Script file - Script
  4. Run the following command to provide permission to the script:
    chmod 777 restore_mysqluser.py
  5. Run the script using the following command:
    cd /var/TKLC/db/filemgmt/user_backup_restore
    ./restore_mysqluser.py
    An output file (DUMP_COMMANDS_<YYYY_MM_DD_HR_MIN_SEC>.sql) is generated in the following path /var/TKLC/db/filemgmt/user_backup_restore.
  6. Run the following command on MySQL database to retrieve custom users configured:
    select user from mysql.user;
  7. Perform the SDS upgrade.
  8. After the upgrade is completed, run the following restore command:
    cd /var/TKLC/db/filemgmt/user_backup_restore
    sudo Imysql -uroot -pImysql23root mysql < DUMP_COMMANDS_<YYYY_MM_DD_HR_MIN_SEC>.sql
    For example:
    sudo Imysql -uroot -pImysql23root mysql < DUMP_COMMANDS_2023_10_30_07_17_19.sql
  9. Run the following command on MySQL database, to ensure custom users are restored:
    select user from mysql.user;
  10. Compare the output of step 6 and 9 to ensure the script has successfully restored the MySQL custom users.
  11. To remove the following files:
    • old user file (user_<YYYY_MM_DD_HR_MIN_SEC>.txt)
    • log file (log_create_sql_<YYYY_MM_DD_HR_MIN_SEC>.txt)
    • .sql generated files (DUMP_COMMANDS_<YYYY_MM_DD_HR_MIN_SEC>
    • .sql, (USER_COMMANDS_<YYYY_MM_DD_HR_MIN_SEC>.sql)
    Run the following command:
    ./restore_mysqluser.py --clean