How to Move Mautic to Another Server

Written by
on September 21, 2018

So you have Mautic running on your web server along with your website, but now you need to move Mautic along with your website to a new server? Good news! Migrating Mautic to another server is a walk in the park.

The instructions below are going to show you how to dump the mysql database from the command line in Debian/Ubuntu, import to a new db and migrate your Mautic installation. Let’s get to it!

Export Your MySQL Database

Assuming the name of your database is ‘mymautic’ and your username is ‘henry’ type the following at the command line:

mysqldump -u henry -p mymautic > whateveryouwant.sql

The – u signifies ‘username’ and the -p signifies ‘password’ which you’ll be prompted for after entering in the above.

The contents of your database will now be in the ‘whateveryouwant.sql’ file, and that will most likely be in your server /root/ directory. Not the server root, but the ‘root’ directory — That tripped me up in the past!

Create New Database & User

Create a new database on the new server. Sign into MySQL:

mysql -u root -p

Then type in the following, assuming you’re going to use the same db name and user name as above (you don’t have to):

create database;

And to grant access:

grant all on mymautic.* to ‘henry’ identified by ‘put-a-tough-password-here’;

Be sure to actually use the single quotes in the command above. Now you’re ready to import.

Import to New Database

It’s time to import. Copy the ‘whateveryouwant.sql’ file to the same /root/ directory on the new server. Then type:

mysql -u henry -p -h localhost mymautic < whateveryouwant.sql

Copy Mautic Files

Nice! The hardest part of your Mautic migration is done. Now copy your Mautic sub folder to the same place on your new server. Once the copy is finished, make sure www-data has proper rights. Assuming Mautic is contained in a ‘content’ folder, type in the following:

chown -R www-data:www-data /var/www/

Your Mautic migration is almost done!

Edit Config File & Clear Cache

Open the /content/app/config/local.php file and update the database name, user and password (if different). Then delete the /content/app/cache folder.

Make sure your nginx server block file is configured to look in the right folder and you’re ready to go. See installing Mautic in a subfolder for more information.

That’s it! As promised, moving Mautic to another server is a walk in the park!

4 thoughts on “How to Move Mautic to Another Server

  1. You my also need update the local.php file configuration to update the path of the site on the new server. (Cache dir, logs dir….)

  2. I keep getting DB connection error. Checked local.php file, everything looks good. Tried manually connecting to DB from shell with credentials and all worked fine.

    Any clues ?

    1. When you type the command to import the database it should prompt you for the ‘henry’ user password. Is it doing that? Make sure you’re specifying the user you created and granted access to the db.

Leave a Reply

Your email address will not be published. Required fields are marked *

Do NOT follow this link or you will be banned from the site!