Migrating MySQL to a new server

When you need to migrate a MySQL server instance to a new server for any reason, eg upgrade of hardware, distri upgrade,… you can easily do the following:

Migrating the databases
On the “old” mysql server, you need to export all databases by:

Copy your sql dump file with eg rsync

On the new server, import your dumps:

Migrating the users

If you are migrating to the same MySQL version you can export all users and settings by dumping the mysql database itself.

and just copy & import of that file on the new server

However, when doing a MySQL version upgrade, we need to export all the Users and their privileges.

Here’s an easy bash script to do this.

Copy the lines between the ———————-

Login on your new server, go to the mysql shell via the admin user

And paste the output from our previous script.

Et Voila, your databases and users are migrated!

 

Increase size of a tmpfs mounted drive

When you are using a tmpfs drive to speed up certain files/folders (eg var/cache from a Magento webshop), and your assigned amount of memory is too small, you can easily increase this by doing  the following:

Modify your tmpfs mount in /etc/fstab to look something like this: (let’s say that I’ve changed the size of 64M to 128M

You can then remount the tmpfs drive by typing

To verify, simply type

Note: Be careful not too increase it too much! Your system will deadlock since the Out-Of-Memory handler can not free up that space if needed

Configure Postfix SMTP Relay with authentication

  • Add the following to /etc/postfix/main.cf

  • Create file: /etc/postfix/smarthost.conf with content:

  • Execute:

  • Reload postfix service:

  • Send a test email via: