📑 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 kullanıcı_adı -p veritabanı_adı > yedek.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 up to 95% 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:

    • Client-side AES-256 encryption: Your SQL database backup is encrypted with AES-256 before it leaves the server.
    • Restore Drill (automatic verification): Backups are verified automatically every week — whether the archive opens, whether the content is complete and whether the checksum matches.

    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?

    It can for files, but not for a database dump: every time mysqldump runs it produces the entire dataset, and a half dump cannot be restored. That is why Yedekalma works incrementally for the file and email components but takes the database in FULL every time. 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 encrypted cloud storage.

    Start Your Free Trial