# Restore "blank" DB

**Date: 2020-09-03**

**Procedure to restore previous executions**

**​**Create a procedure to restore all the old (previous) data and the ability of AIQ to handle.

1. Create a backup for current and active aiq (need to be performed having aiq offline) as below.
 
`​$ mysqldump -u root -p aiq > <path>\currentaiq.sql`

2\. Drop aiq schema and creation of a new aiq blank schema, this needs to be addressed using MysqlWorkbench and connected as root.

`drop schema aiq;`

`create schema if not exists `aiq` default character set utf8 collate `

`utf8_general_ci;`

3\. Restore the database of previous executions to point of failure, performing as below.  
`$ mysql -u root -p aiq < <path>\aiqbq.sql`

4\. Execute as root the attached sql script **renameWindows.sql**, it'll perform the following.

   
a. create the **aiq\_old** schema

b. grant permissions to **aiq** user for **aiq\_old** schema

b. rename aiq's tables to aiq\_old schema

c. create views, functions, stored procedures for **aiq\_old** schema

5\. Drop aiq schema and creation of a new aiq blank schema, this needs to be addressed using MysqlWorkbench and connected as root.  
  
`drop schema aiq;`

`create schema if not exists `aiq` default character set utf8 collate `

`utf8_general_ci;`

6\. Restore current aiq schema again using the backup created in the first step.  
$ mysql -u root -p aiq &lt; `<path>\currentaiq.sql`

<span>[](../../Resources/Images/GeneralGraphics/renameWindows.sql)</span><span>[](../../Resources/Images/GeneralGraphics/renameLinux.sql)</span>

<div id="bkmrk-last-updated%3A-july-0">---

Last updated: <span class="mc-variable General.NewDateTimeVariable variable">July 03, 2023</span>

If you have any feedback on this topic, please contact us at <documentation@appvance.ai>

</div>