Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
MariaDB Cookbook

You're reading from   MariaDB Cookbook Learn how to use the database that's growing in popularity as a drop-in replacement for MySQL. The MariaDB Cookbook is overflowing with handy recipes and code examples to help you become an expert simply and speedily.

Arrow left icon
Product type Paperback
Published in Mar 2014
Publisher
ISBN-13 9781783284399
Length 282 pages
Edition Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Daniel Bartholomew Daniel Bartholomew
Author Profile Icon Daniel Bartholomew
Daniel Bartholomew
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

MariaDB Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started with MariaDB FREE CHAPTER 2. Diving Deep into MariaDB 3. Optimizing and Tuning MariaDB 4. The TokuDB Storage Engine 5. The CONNECT Storage Engine 6. Replication in MariaDB 7. Replication with MariaDB Galera Cluster 8. Performance and Usage Statistics 9. Searching Data Using Sphinx 10. Exploring Dynamic and Virtual Columns in MariaDB 11. NoSQL with HandlerSocket 12. NoSQL with the Cassandra Storage Engine 13. MariaDB Security Index

Creating a backup user


It is a bad idea to use a super user like root for making backups. One main reason is that backups often run automatically, and so the password has to be stored somewhere (for example, in the my.cnf file). If the user that is being used for backups has full access to the database, it could be abused, or an error in a backup script could cause all sorts of trouble.

In this recipe, we will create a backup user with the minimum permissions necessary to run both the mysqldump and XtraBackup programs.

How to do it…

Let's get started by following the ensuing steps:

  1. Launch the mysql command-line client.

  2. Create the backup user. For this recipe, we'll call the user backupuser and give the user the password p455w0rd. The user can be named anything we wish, and the password should definitely be changed to something unique:

    CREATE USER 'backupuser'@'localhost'
        IDENTIFIED BY 'p455w0rd';
    
  3. Next, we will grant our new user a minimal set of permissions, just enough so that it can make backups as follows:

    GRANT SELECT, SHOW VIEW, LOCK TABLES, RELOAD,
        REPLICATION CLIENT
        ON *.* TO 'backupuser'@'localhost';
    
  4. Lastly, we will use the FLUSH PRIVILEGES command to force MariaDB to reread the privileges table, which is always a good idea after granting new privileges to a user.

    FLUSH PRIVILEGES;
    

How it works...

There's no need for the user we use to make backups in order to have every privilege on our databases. They only need a specific subset. For example, they don't need the INSERT or ALTER TABLE privileges since backup users just need to read the tables in our databases. The set of privileges in this recipe are enough for both the XtraBackup and mysqldump programs, and will likely be sufficient for other backup programs as well.

You have been reading a chapter from
MariaDB Cookbook
Published in: Mar 2014
Publisher:
ISBN-13: 9781783284399
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime