Book Image

Getting Started with MariaDB

By : Daniel Bartholomew
Book Image

Getting Started with MariaDB

By: Daniel Bartholomew

Overview of this book

MariaDB is a database that has become very popular in the few short years that it has been around. It does not require a big server or expensive support contract. It is also powerful enough to be the database of choice for some of the biggest and most popular websites in the world, taking full advantage of the latest computing hardware available. From installing and configuring through basic usage and maintenance, each chapter in this revised and expanded guide leads on sequentially and logically from the one before it, introducing topics in their natural order so you learn what you need, when you need it. The book is based on the latest release of MariaDB and covers all the latest features and functions. By the end of this beginner-friendly book, not only will you have a running installation of MariaDB, but you will have practical, hands-on experience in the basics of how to install, configure, administer, use, and maintain it.
Table of Contents (16 chapters)
Getting Started with MariaDB Second Edition
About the Author
About the Reviewers
MariaDB Next Steps


Databases are all around us. Almost every website we visit and nearly every store we shop at has a database (or several) working quietly behind the scenes. The same goes for banks, hospitals, government agencies, theaters, doctors, hospitals, amusement parks, and police departments. All use databases to store, sort, and analyze their own particular information.

This information comes in many forms and can be anything that can be stored electronically inside a computer. This includes books, catalogs, addresses, names, dates, finances, pictures, money, passwords, documents, preferences, tweets, posts, likes, blogs, articles, and much more. Databases are one of the foundational pillars of the modern electronic world.

Your posts on Facebook and tweets on Twitter are stored in a database. All your financial information in your bank is stored in a database. Your purchase history at your favorite online retailer is too. How about your progress in your favorite online game? You guessed it. What about the record of when you last paid your water bill? That too! You just can't get away from databases. They are, quite literally, everywhere.

There is a new database that has caught the attention of the database community over the past few years like few others have. First released in 2009, its name is MariaDB—named after the youngest daughter of its creator, Michael "Monty" Widenius.

MariaDB may be younger than the databases it is often compared with, but it has a stellar parentage. It's a next-generation evolution of the popular MySQL database, also created by Monty (you may have heard of it, but don't worry if you haven't).

MariaDB is open source. This means that the source code is freely downloadable and is governed by a license that helps ensure the source code stays free and open to all. The MariaDB developers have also kindly provided installers for various operating systems.

Since its first release, MariaDB has gained a large, loyal following faster than almost any other database. Today, it powers tens of thousands of websites, big and small, and is the database of choice for many companies in a wide variety of industries around the world with hundreds of thousands of users.

The great news is that we can install and use it ourselves, right now, on our personal laptop and desktop computers. For all of its power—and MariaDB is a very powerful and capable database, make no mistake—it is very easy to install and use.

This book provides an introduction to MariaDB that is enough to get us started. Don't worry if you've never used a database before - this book covers everything you need to know, and before you know it, you'll be on your way to becoming an expert database administrator (DBA). But even if you never move beyond just tinkering or playing around with MariaDB, you'll learn about one of the fundamental technologies of our times.

Not a bad accomplishment over a weekend or two.

What this book covers

Chapter 1, Installing MariaDB, explains how to install MariaDB on Windows, Linux, and Mac OS X.

Chapter 2, Configuring MariaDB, explains the basics of configuring MariaDB, including the location of the configuration files and how to set common configuration options.

Chapter 3, Securing MariaDB, provides an overview of the best practices for MariaDB security, including how to easily secure a new MariaDB installation.

Chapter 4, Administering MariaDB, explains how to add and administer MariaDB user accounts.

Chapter 5 , Using MariaDB – Databases and Tables, covers the commands used to create, update, and delete databases and tables.

Chapter 6, Using MariaDB – Inserting, Updating, and Deleting, covers the commands used to add, update, and delete data from our database tables.

Chapter 7, Using MariaDB – Retrieving Data, covers the commands used to retrieve data from our database tables, including filtering, searching, sorting, joining, and summarizing the data.

Chapter 8, Maintaining MariaDB, explains how to maintain your MariaDB database and keep it running smoothly.

Appendix, MariaDB Next Steps, provides you with a list of various online resources available to help you on your way to becoming a MariaDB expert.

What you need for this book

To get the most out of this book, you will need a computer with Windows, any version from XP to Windows 8 would do; Mac OS X; or one of the Linux distributions: Ubuntu, Debian, Fedora, CentOS, or Red Hat. MariaDB runs on many more operating systems and distributions, but these are the ones that are specifically mentioned and discussed in this book.

To install MariaDB, you will need an Internet connection and the necessary administrative rights to install software.

To edit MariaDB configuration files, you will need a text editor. Notepad is a good universal choice on Windows. TextEdit and TextWrangler work well on Mac OS X. There are many excellent text editors on Linux, just pick a favorite: Vim, gedit, nano, pluma, and emacs are all good choices. A word processor, such as Word, Wordpad, OpenOffice, Pages, or LibreOffice, will not work.

No other software is required.

Who this book is for

This book is for anyone who wants to learn more about databases in general, and/or MariaDB in particular. To get the most out of this book, you only need to be comfortable installing software on your computer, editing files with a text editor, and using the command line and terminal. Prior database experience is not required.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "As mentioned previously, the ZIP files are similar to the Linux binary .tar.gz files and they are only recommended for those who know that they want it."

A block of code is set as follows:

CREATE TABLE employees (
    surname VARCHAR(100),
    givenname VARCHAR(100),
    pref_name VARCHAR(50),
    birthday DATE COMMENT 'approximate birthday OK'

Any command-line input or output is written as follows:

brew doctor

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "The Install as service box is checked by default, and it is recommended to keep it that way so that MariaDB starts up when the computer is booted."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.