Categories
Knowledge Support Cloudvue Cloudvue Gateway Support Categories

Dropping and Creating the smartvuedb Database

Description 

At times it may be necessary to drop (delete) and create the smartvuedb database.  WARNING VIDEO LOSS is expected, and except for rare occasions this should only be performed on newly deployed NVRs.

Product 

Cloudvue Gateway

Prerequisite

  • ssh access to the Cloudvue Gateway
  • see KB #13051 “Cloudvue SSH Tunneling” or KB #13667 “Tunneling to a Cloudvue Gateway From a Local Windows Machine”

Solution

Issue the following commands from terminal

** WARNING ** WILL RESULT IN VIDEO LOSS

<code>sudo service cron stop <br>mysqldump -u root -p smartvuedb camera camera_setting camera_view nvr_setting schedule user user_setting user_Status User_view view > /home/smartvue/smartvuedb_backup.sql <br>sudo mysql smartvuedb -s -e “drop database smartvuedb;”<br>sudo mysql -s -e “create database smartvuedb;”<br>sudo -i <br> bash /opt/smartvue/services/nvr-database-migrate/installer.sh<br>bash /smartvue/updater.sh<br>mysql -u root smartvuedb -p < /smartvue/mysql/multi-tables_smartvuedb_backup_file.sql<br>exit<br>sudo service cron start</code>


Command Explanation

cron stop – Stops scripts from being launched by cron during this process

msyqldump – (Optional) can be used to create a backup of specified tables within the existing smartvuedb database

drop database smartvuedb – Removes the existing smartvuedb database

create database smartvuedb – creates an empty smartvuedb database

sudo -i – switch to root user

installer.sh – runs the installer script which sets permissions for smartvuedb and will return the following lines if successful

++ pwd -P <br>+ SERVICE_DIR=/root <br>SERVICE_DIR=/root <br>SMV_NVR_DB_USER=root <br>/root/node_modules/db-migrate/bin/db-migrate up <br> /opt/smartvue/services/nvr-database-migrate/installer.sh: line 4: /root/node_modules/db-migrate/bin/db-migrate: No such file or directory <br>exit 127

updater.sh – runs the updater script which populates default values in certain tables within smartvuedb database and takes several minutes to complete.

mysql -u root smartvuedb -p – (Optional) can be used to import tables previously backed up with the mysqldump

cron start – Starts cron service