# How to move Sonata Stats to a remote server?

**URL:** https://forums.vitalpbx.org/t/how-to-move-sonata-stats-to-a-remote-server/1244
**Category:** FAQ
**Created:** [April 21, 2022, 2:24pm UTC](https://forums.vitalpbx.org/t/how-to-move-sonata-stats-to-a-remote-server/1244 "2022-04-21T14:24:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![admin](https://forums.vitalpbx.org/user_avatar/forums.vitalpbx.org/admin/32/3_2.png) [@admin](https://forums.vitalpbx.org/u/admin)
#### Post date: [April 21, 2022, 2:24pm UTC](https://forums.vitalpbx.org/t/how-to-move-sonata-stats-to-a-remote-server/1244/1 "2022-04-21T14:24:35Z")

</div>

If you’d like to move Sonata Stats to another server, to reduce the load on the main VitalPBX server.

- First, install the Sonata Stats on your new server.

- Then, you will need to edit this file _ **/usr/share/queues-stats/backend/.env** _

```auto
DB_ASTERISK_HOST=VITALPBX_IP_SERVER
DB_ASTERISK_PORT=3306
DB_ASTERISK_USERNAME=REMOTE_MYSQL_USER
DB_ASTERISK_PASSWORD=REMOTE_MYSQL_SECURE_PWD

```

On this configuration, you will need to enter the IP address of the asterisk, server port, and credentials

- In the Linux CLI, execute the command below.

```auto
mysql -uroot -e"create database sonata_stats"

```

- Create a user with all permissions for the sonata\_stats database.

```auto
mysql -uroot
grant all privileges on sonata_stats.* to "stats"@"localhost" identified by "SECURE_PWD"

```

- On the _ **.env** _ file edit these configurations and enter the credentials created in the previous step.

```auto
DB_USERNAME=stats
DB_PASSWORD=SECURE_PWD

```

- From this location _ **/usr/share/queues-stats/backend** _ execute these commands

```auto
php artisan config:cache
php artisan migrate

```

- To create our admin user, we have to execute the command below.

```auto
php artisan tinker

```

Then, we have to paste the following code.

```auto
use App\Role;
use App\User;

$user = User::updateOrCreate(
  ['name' => 'admin'],
  ['password' => 'enter your password here',
  'full_name' => 'admin',
  'tenant_id' => 1,
  'tenant' => 'vitalpbx']
);

$user->roles()->sync(Role::where('name', 'admin')->first());

```

Finally, edit the file _ **/var/lib/sonata/stats/wizard.conf** _ and configure the flag below.

```auto
installed=yes

```

Now, you should be able to access sonata stats from your new server.
