📑 Table of Contents

    Whether you run an e-commerce site, a mobile app backend, a membership system or a blog, your website's most valuable data — user passwords, orders, settings and content — lives in the MySQL database. If you lose your files you can rewrite the code; losing your database causes damage, financial and otherwise, that cannot be undone. In this article we've gathered the best security settings and backup strategies you can apply to protect your MySQL database.

    1. MySQL Database Security (Hardening Measures)

    Protecting your database against outside attacks matters just as much as backing it up. Apply these basic steps to prevent intrusions:

    Close Off External Access (Bind Address)

    Having your MySQL server exposed to the outside world is a major vulnerability. To allow only localhost (on-server) connections, check the bind-address setting in your my.cnf or mysqld.cnf file:

    bind-address = 127.0.0.1

    With this setting, direct connection attempts to your database from outside the server are blocked.

    Block Remote Connections for the Root User

    The MySQL root user has full privileges and is a common target for brute-force attacks. Make sure the root user can only connect from within the server:

    ALTER USER 'root'@'%' IDENTIFIED BY 'CokGucluSifre123!';
    -- For localhost-only access:
    RENAME USER 'root'@'%' TO 'root'@'localhost';

    🚨 Ransomware and Data Breaches

    In recent years automated bots have been scanning for exposed MySQL ports (3306) with weak passwords, encrypting the data and demanding a ransom. Strong passwords and restricting access to localhost reduce these risks considerably.

    2. The Safest mysqldump Backup Method

    The most common way to back up MySQL databases is the mysqldump command. On large databases, though, you need the right parameters to avoid locking the tables while the backup runs:

    mysqldump --single-transaction --quick --lock-tables=false -u username -p database_name > backup.sql
    • --single-transaction: lets you take the backup without locking tables. Operations don't stall while your site is live.
    • --quick: writes rows straight to the file, preventing excessive memory use on large databases.

    3. What Is MySQL Incremental Backup?

    If your database is 5 GB or larger, taking a full backup from scratch every day both taxes the server CPU and eats through disk space quickly.

    An incremental backup captures only the rows changed or added since the last backup. Done using MySQL's binary log technology, this approach saves a significant amount of disk space and server traffic.

    4. Secure, Automated MySQL Backups with Yedekalma

    Taking and storing backups by hand is laborious and open to human error. Yedekalma backs up your MySQL database from your own server automatically and securely:

    • Optional AES-256 encryption: When you turn it on, your SQL database backup is encrypted on your site’s server with a passphrase only you know and reaches your storage encrypted; we do not store the passphrase and cannot open it either.
    • 8-layer verification: For every backup, coverage, the completeness of the database dump, integrity and whether the backup is still at its destination are checked automatically; in addition, a weekly sample restore test downloads selected archives on your server and verifies that they open.

    Frequently Asked Questions

    How do you back up a MySQL database?

    The most common way is the mysqldump command: `mysqldump -u user -p database > backup.sql`. Don't put the password on the command line (it shows up in the process list); use a ~/.my.cnf file or --defaults-extra-file instead. For small databases the Export tab in phpMyAdmin is also enough, but on large tables it can hit a PHP timeout.

    How often should a MySQL backup be taken?

    The measure is how much time's worth of data you can afford to lose (your RPO). On a static brochure site a weekly backup may be enough; a site with daily content needs a daily backup; an e-commerce site taking orders needs an hourly one — because there, an hour of loss means lost orders.

    Can incremental backup be used for a database backup?

    At table level, not at row level: every time mysqldump runs it produces the selected tables in full, and a half dump cannot be restored. In Yedekalma's PHP Backup Module the incremental mode is optional: for files it looks at modification times, for email at IMAP UIDs; in the database, after a full backup only the tables whose table-level checksum (CHECKSUM) changed are dumped again. These dumps are always relative to the last full backup (differential); manually started backups are always full, and the full backup is refreshed periodically. In the WordPress plugin and in chunked mode for very large sites, the database is not incremental: a full dump is taken on every run. True incremental database recovery is done with binlog-based PITR and is a separate topic.

    Do I have to share my database password with the backup service?

    No. In Yedekalma the dump is taken by the PHP module running on your own server; the MySQL username and password stay in the configuration file on your server and are never sent to a Yedekalma server. The panel only sees the backup's metadata (size, date, checksum).

    Don't Leave Your Database Security to Chance

    Set up your MySQL backup plan with Yedekalma in five minutes and keep your data automatically in your own cloud storage, with optional encryption.

    Start Your Free Trial