Skip to content

Instantly share code, notes, and snippets.

@nakamuraos
Last active June 25, 2024 03:33
Show Gist options
  • Save nakamuraos/717eb99b5e145ed11cd754ad3714b302 to your computer and use it in GitHub Desktop.
Save nakamuraos/717eb99b5e145ed11cd754ad3714b302 to your computer and use it in GitHub Desktop.
Reset trial Navicat 15, Navicat 16, Navicat 17 on Linux
#!/bin/bash
# Author: NakamuraOS <https://github.com/nakamuraos>
# Latest update: 06/24/2024
# Tested on Navicat 15.x, 16.x, 17.x on Debian, Ubuntu.
BGRED="\e[1;97;41m"
ENDCOLOR="\e[0m"
echo -e "${BGRED} ${ENDCOLOR}"
echo -e "${BGRED} ┌──────────────────────────────────────┐ ${ENDCOLOR}"
echo -e "${BGRED} │ !!! WARNING !!! │ ${ENDCOLOR}"
echo -e "${BGRED} ├──────────────────────────────────────┤ ${ENDCOLOR}"
echo -e "${BGRED} │ ALL DATA can be destroyed. │ ${ENDCOLOR}"
echo -e "${BGRED} │ Always BACKUP before continuing. │ ${ENDCOLOR}"
echo -e "${BGRED} └──────────────────────────────────────┘ ${ENDCOLOR}"
echo -e "${BGRED} ${ENDCOLOR}"
echo -e "Report issues:\n> https://gist.github.com/nakamuraos/717eb99b5e145ed11cd754ad3714b302\n"
echo -e "Reset trial \e[1mNavicat Premium\e[0m:"
read -p "Are you sure? (y/N) " -r
echo
if [[ $REPLY =~ ^[Yy]([eE][sS])?$ ]]
then
echo "Starting reset..."
DATE=$(date '+%Y%m%d_%H%M%S')
# Backup
echo "=> Creating a backup..."
cp ~/.config/dconf/user ~/.config/dconf/user.$DATE.bk
echo "The user dconf backup was created at $HOME/.config/dconf/user.$DATE.bk"
cp ~/.config/navicat/Premium/preferences.json ~/.config/navicat/Premium/preferences.json.$DATE.bk
echo "The Navicat preferences backup was created at $HOME/.config/navicat/Premium/preferences.json.$DATE.bk"
# Clear data in dconf
echo "=> Resetting..."
dconf reset -f /com/premiumsoft/navicat-premium/
echo "The user dconf data was reset"
# Remove data fields in config file
sed -i -E 's/,?"([A-F0-9]+)":\{([^\}]+)},?//g' ~/.config/navicat/Premium/preferences.json
echo "The Navicat preferences was reset"
# Done
echo "Done."
else
echo "Aborted."
fi
@nakamuraos
Copy link
Author

nakamuraos commented Jan 4, 2022

Please close Navicat Premium before run this script.
You can also need re-run this script some times if it's not working.

@nakamuraos
Copy link
Author

nakamuraos commented Mar 28, 2022

Background Knowledge

Configuration structure

  • Navicat creates the directory ~/.config/navicat to store configuration data:

    /home/user/.config/navicat
    ├── Premium
       ├── preferences.json
       ├── preferences.json.lock
       ├── Profiles
          ├── Clouds
          └── vgroup.json
       └── ui_preferences.json
    ├── Common
       ├── connections.json
       ├── connections.json.lock
       └── ui_connections.json
    ├── Settings
       └── ...
    └── MySQL
        └── Profiles
            └── ...
  • Navicat uses dconf in Linux to store user configuration data:

    • You can see the com/premiumsoft/navicat-premium section below:
      # nano ~/.config/dconf/user.conf
      ...
      [apps/light-locker]
      idle-hint=false
      late-locking=false
      lock-after-screensaver=uint32 5
      lock-on-lid=false
      lock-on-suspend=true
      
      [com/premiumsoft/navicat-premium]
      019C981BDC7F0FD22F2F2886AF209C85='84AA0BE73C5C83CF48CF06B475B05B9D'
      0231EE5D1EF3A65D643D0D2DB15D3224='ABCD8AEC6CDC496375CC38A64AC1BE78'
      023AECCA316B6E832F6D9664FC85369B='FE81DC33B14E9129F5BEA7F87BC6686B'
      02771B3A8E4CA9456C24A43DF59C216F='625AE8702A2103E997B6394300A7FCE4'
      ...
      F9D5C7D0000DB83FB3100311BC54777C='034E5755BB39A9393272D9970B57074E'
      FC800E08E45E56E518CA9B2C7DE3FDBE='034E5755BB39A9393272D9970B57074E'
      FC800E08E45E56E518CA9B2C7DE3FDBE='034E5755BB39A9393272D9970B57074E'
      last-check-time=int64 1648194098
      
      [org/blueman/general]
      window-properties=[558, 350, 555, 125]
      
      [org/blueman/network]
      nap-enable=false
      
      [org/blueman/plugins/powermanager]
      auto-power-on=@mb true
      ...
    • Note: The above file was generated using the command:
      dconf dump / >~/.config/dconf/user.conf
      To see how to use the dconf command, run dconf -h

Solution

  • This simple solution is to delete all keys in the com/premiumsoft/navicat-premium directory (referred to as dir by dconf, which is a virtual directory):
    # Check key list
    dconf list /com/premiumsoft/navicat-premium/
    
    # The DIR must starting and ending with '/'
    dconf reset -f /com/premiumsoft/navicat-premium/
    
    # Verify, empty is successful
    dconf list /com/premiumsoft/navicat-premium/

Summary

  • The simple final bash script will look like this:
    #!/bin/bash
    
    # Backup
    cp ~/.config/dconf/user ~/.config/dconf/user.bk
    cp ~/.config/navicat/Premium/preferences.json ~/.config/navicat/Premium/preferences.json.bk
    
    # Clear data in dconf
    dconf reset -f /com/premiumsoft/navicat-premium/
    # Remove data fields in config file
    sed -i -E 's/,?"([A-Z0-9]+)":\{([^\}]+)},?//g' ~/.config/navicat/Premium/preferences.json

Maintainer

@nakamuraos
Copy link
Author

This is part of my research. Please subscribe their plan if you can.

@BCisneros97
Copy link

Works like a charm thanks !!

@aji1904
Copy link

aji1904 commented Jan 8, 2023

it works

@dotmitsu
Copy link

dotmitsu commented Apr 7, 2023

It works. Thanks

@angelsv
Copy link

angelsv commented Apr 25, 2023

Can anyone integrate this great work along with the following great contribution?:

https://notabug.org/doublesine/navicat-keygen/src/linux

@L1so
Copy link

L1so commented Apr 25, 2024

Does this script will reset settings ? So if I save connection, will this script erase it?

@nakamuraos
Copy link
Author

Does this script will reset settings ? So if I save connection, will this script erase it?

No. It'll keep all current settings, your connections will remain in place.

@Cien267
Copy link

Cien267 commented May 6, 2024

I got this error: reset-trial-navicat.sh: 23: [[: not found
Did I do something wrong?

@dotmitsu
Copy link

dotmitsu commented May 6, 2024

I got this error: reset-trial-navicat.sh: 23: [[: not found Did I do something wrong?

Run it as sudo

@Cien267
Copy link

Cien267 commented May 6, 2024

I got this error: reset-trial-navicat.sh: 23: [[: not found Did I do something wrong?

Run it as sudo

still the same error bruh :<

@dotmitsu
Copy link

dotmitsu commented May 6, 2024

still the same error bruh :<

What distro do you use?

@Cien267
Copy link

Cien267 commented May 6, 2024

What distro do you use?

I am using Ubuntu 22.04

@dotmitsu
Copy link

dotmitsu commented May 6, 2024

What distro do you use?

I am using Ubuntu 22.04

Can you show screenshot how do run command, and the result? It works good on ubuntu 22.04

@Cien267
Copy link

Cien267 commented May 6, 2024

image
that's my terminal

@dotmitsu
Copy link

dotmitsu commented May 6, 2024

@Cien267 use
sudo ./reset-trial-navicat.sh
I think this script uses bash commands in it. And sh can't normally execute

@Cien267
Copy link

Cien267 commented May 6, 2024

@dotmitsu
I try chmod +x and run "./" instead of "sh" and it works. Thank you very much <3

@swatchion
Copy link

confirm it works on 17.0

@nakamuraos
Copy link
Author

confirm it works on 17.0

It's great to hear that 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment