Migrating a MySQL database containing views

You may have come across this problem: say you have a MySQL database called ‘myblog’ which you’re moving to a new server on a different provider, and said provider doesn’t allow you to name the database, but instead use their own scheme, ‘user82_db1’ for example.

If you happen to have views in your database, this will cause the import to fail, as those views would still refer to ‘myblog’ instead of the new database. Fortunately, this is easily fixed using the ‘rpl’ command. Say your database is backed up as ‘myblog-backup.sql’:

# rpl "\'myblog\'." "\'user82_db1\'." myblog-backup.sql

This will replace any instance to ‘myblog.’ with ‘user82_db1.’ and allow you to import a working database.

Plesk: Finding large log files

I get this kind of problem every day: “We’ve run out of disc space on our Plesk server – what’s taking up all the space?” The answer, almost every time, is “logs.” Plesk doesn’t enable log rotation by default, so logs can end up taking a lot of space.

Here’s something I cooked up to list the size of each domain’s log directory:

Continue reading “Plesk: Finding large log files”

SMTP status codes

Have you ever wondered what all those SMTP status codes mean? It’s not that hard to read. Each code consists of three numbers. The format for this is class.subject.detail, for example 2.5.0 (also written as 250).

Here is a list of the classes:

2.x.x - Succes
4.x.x - Temporary failure
5.x.x - Permanent failure

Here are the subjects:

x.0.x - Other or undefined
x.1.x - Addressing related
x.2.x - Mailbox related
x.3.x - Mail system related
x.4.x - Network or routing related
x.5.x - Mail delivery protocol related
x.6.x - Message content related
x.7.x - Security or policy related

Continue reading “SMTP status codes”