Chapter 18 · Using the MariaDB Database Management System
Chapter Overview
After Oracle acquired the MySQL project, MySQL gradually shifted from a community-driven open‑source model toward a more closed, commercially patented one. That change pushed many companies and vendors to adopt MariaDB as their preferred database. Thanks to its open‑source roots and solid stability, MariaDB quickly became a popular drop‑in replacement for MySQL.
This chapter starts with foundational concepts of databases and database management systems, then dives into MariaDB’s features. Through hands‑on labs you will practice everyday administration: creating and managing users, granting permissions, creating databases and tables, and performing the core CRUD operations (create, read, update, delete). We then cover backup and restore so that, beyond mastering CRUD, you can competently manage databases in production.
18.1 Database management systems
A database is a repository that stores data in an organized structure. In today’s era of big data, the internet generates massive volumes of information every day. Database technology has evolved from simple, single‑host tables to large‑scale, distributed storage. Effective management and use of this data—extracting value from it—is essential to scientific research and decision‑making. Databases are core components of information management systems, office automation, and decision support systems.
A database management system (DBMS) is software that searches, modifies, deletes, and maintains data in databases. By mapping low‑level physical data into higher‑level logical structures, a DBMS lowers the barrier to data administration—so even Linux operations engineers can perform basic database tasks. Still, remember that this book’s main line is Linux operations; databases are an important side branch that broadens and deepens that line. You won’t “master” database administration in a day or two. If you develop a strong interest after this chapter and want a DBA role, build a focused study plan and keep going.
We can’t discuss databases without mentioning MySQL. MySQL is widely deployed worldwide and known for maturity, simple configuration, and good scalability. When Oracle acquired Sun in 2009, MySQL came under Oracle’s umbrella and gradually moved toward “open source in name, but protected by multiple commercial patents.” Because open‑source software represents the collective effort of global hackers, geeks, and programmers, commercialization without broad community alignment frustrated many contributors. In response, MySQL’s original founder launched a new database: MariaDB.
Figure 18‑1 shows the MariaDB and MySQL logos.
Figure 18-1 Logos for the MariaDB and MySQL DBMSs
MariaDB was created by MySQL founder Michael “Monty” Widenius. As the official site explains, Widenius named MySQL after his older daughter, My, and MariaDB after his younger daughter, Maria:
Why is the Software Called MariaDB?
The 'MySQL' name is trademarked by Oracle, and they have chosen to keep that trademark to themselves. The name MySQL (just like the MyISAM storage engine) comes from Monty's first daughter My. The first part of 'MySQL' is pronounced like the English adjective, even if this doesn't match the correct pronunciation of the Finnish name.
MariaDB continues this tradition by being named after his younger daughter, Maria.
The name Maria was initially given to a storage engine. After MariaDB was started, to avoid confusion, it was renamed to Aria. The new name was decided as a result of a contest.
MariaDB is community‑maintained, forked from MySQL, and highly compatible with it. The APIs and commands are effectively the same. MariaDB also introduced the Aria storage engine (a successor to MyISAM). In daily use, MariaDB works just as smoothly as MySQL.
As corporate strategies diverged—and as MySQL’s governance shifted—many organizations switched. Google and Wikipedia migrated workloads from MySQL to MariaDB. Red Hat made MariaDB the default DBMS in recent RHEL, CentOS Stream, and Fedora releases and added database topics to the RHCE exam. Other distributions—including openSUSE and Slackware—announced similar moves.
To be candid, this does not mean MariaDB dramatically outperforms MySQL across the board. After nearly two weeks of comparison tests, I found no striking performance advantage touted by some media. Operationally, they’re very similar; the commands are nearly identical. From a practical standpoint, if I can use MariaDB confidently, I can handle MySQL at work with minimal adjustment.
18.2 Initializing the MariaDB service
Compared with MySQL, MariaDB ships a number of notable enhancements: microsecond precision, thread pools, subquery optimization, progress reporting, and more. After configuring your repositories, install the server packages:
Why is the Software Called MariaDB?
The 'MySQL' name is trademarked by Oracle, and they have chosen to keep that trademark to themselves. The name MySQL (just like the MyISAM storage engine) comes from Monty's first daughter My. The first part of 'MySQL' is pronounced like the English adjective, even if this doesn't match the correct pronunciation of the Finnish name.
MariaDB continues this tradition by being named after his younger daughter, Maria.
The name Maria was initially given to a storage engine. After MariaDB was started, to avoid confusion, it was renamed to Aria. The new name was decided as a result of a contest.
Start the service and enable it at boot:
root@linuxprobe:~# dnf install mariadb mariadb-server
Updating Subscription Management repositories.
BaseOS 2.7 MB/s | 2.7 kB 00:00
AppStream 2.7 MB/s | 2.8 kB 00:00
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mariadb x86_64 3:10.11.9-3.el10 AppStream 1.7 M
mariadb-server x86_64 3:10.11.9-3.el10 AppStream 10 M
Installing dependencies:
mariadb-common noarch 3:10.11.9-3.el10 AppStream 35 k
mariadb-connector-c x86_64 3.4.1-1.el10 BaseOS 214 k
mariadb-connector-c-config noarch 3.4.1-1.el10 BaseOS 10 k
mariadb-errmsg noarch 3:10.11.9-3.el10 AppStream 267 k
mysql-selinux noarch 1.0.10-4.el10 AppStream 38 k
perl-DBD-MariaDB x86_64 1.23-6.el10 AppStream 159 k
perl-File-Copy noarch 2.41-510.el10 AppStream 22 k
perl-Sys-Hostname x86_64 1.25-510.el10 AppStream 20 k
Installing weak dependencies:
mariadb-backup x86_64 3:10.11.9-3.el10 AppStream 6.6 M
mariadb-gssapi-server x86_64 3:10.11.9-3.el10 AppStream 18 k
mariadb-server-utils x86_64 3:10.11.9-3.el10 AppStream 263 k
Installed:
mariadb-3:10.11.9-3.el10.x86_64 mariadb-backup-3:10.11.9-3.el10.x86_64
mariadb-common-3:10.11.9-3.el10.noarch mariadb-connector-c-3.4.1-1.el10.x86_64
mariadb-connector-c-config-3.4.1-1.el10.noarch mariadb-errmsg-3:10.11.9-3.el10.noarch
mariadb-gssapi-server-3:10.11.9-3.el10.x86_64 mariadb-server-3:10.11.9-3.el10.x86_64
mariadb-server-utils-3:10.11.9-3.el10.x86_64 mysql-selinux-1.0.10-4.el10.noarch
perl-DBD-MariaDB-1.23-6.el10.x86_64 perl-File-Copy-2.41-510.el10.noarch
perl-Sys-Hostname-1.25-510.el10.x86_64
Complete!
Don’t start using MariaDB just yet. First, secure and initialize it. The mysql_secure_installation
helper walks you through six important steps:
- Enter the current database root password (this is the database root, not the OS root; it’s empty by default—press Enter).
- Switch to
unix_socket
authentication, which is safer and lets you log in locally without a password. - Set a dedicated password for the database root account (used for remote logins; local logins via socket won’t require it).
- Remove anonymous users and disallow database‑root remote logins.
- Delete the default test database and revoke its privileges.
- Reload privilege tables to apply changes immediately.
Example session (with inline notes):
root@linuxprobe:~# systemctl start mariadb
root@linuxprobe:~# systemctl enable mariadb
Created symlink '/etc/systemd/system/mysql.service' → '/usr/lib/systemd/system/mariadb.service'.
Created symlink '/etc/systemd/system/mysqld.service' → '/usr/lib/systemd/system/mariadb.service'.
Created symlink '/etc/systemd/system/multi-user.target.wants/mariadb.service' → '/usr/lib/systemd/system/mariadb.service'.
In many production environments, websites and databases run on separate hosts. If I need remote administrative access for the root account, I adjust the choices above accordingly and then open the firewall. MariaDB listens on 3306; the firewalld service name is mysql
:
root@linuxprobe:~# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
#Enter the administrator's original password. The default value is empty. Just press Enter.
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
... Success!
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
Now I log in for the first time. With unix_socket
enabled, local logins require no password—just run mysql
:
root@linuxprobe:~# firewall-cmd --permanent --add-service=mysql
success
root@linuxprobe:~# firewall-cmd --reload
success
For remote access—or if I prefer to use a password—I specify -u
and -p
:
root@linuxprobe:~# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 13
Server version: 10.11.9-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
New users often type help
to see what the client can do; MariaDB’s syntax is the same as MySQL’s.
root@linuxprobe:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 14
Server version: 10.11.9-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
When running SQL statements, I end each command with a semicolon (;
). That’s different from Linux shell commands and worth getting used to. List the default databases:
MariaDB [(none)]> help
General information about MariaDB can be found at http://mariadb.org
List of all client commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit (\e) Edit command with $EDITOR.
ego (\G) Send command to MariaDB server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to MariaDB server.
help (\h) Display this help.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
nowarning (\w) Don't show warnings after every statement.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
sandbox (\-) Disallow commands that access the file system (except \P without an argument and \e).
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
warnings (\W) Show warnings after every statement.
For server side help, type 'help contents'
18.3 Managing users and privileges
I won’t use the database root
for everything in production. For safety and collaboration, I create dedicated accounts and grant only the permissions they need. As database root, I create a user in the standard form:
MariaDB [(none)]> SHOW databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.001 sec)
User information is stored in the mysql
system database. I can query it with SELECT
:
MariaDB [(none)]> CREATE USER luke@localhost IDENTIFIED BY 'linuxprobe';
Query OK, 0 rows affected (0.001 sec)
Right now, luke
has no privileges. I log in as luke
and try listing databases—only information_schema
appears:
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [mysql]> SELECT HOST,USER,PASSWORD FROM user WHERE USER="luke";
+-----------+------+-------------------------------------------+
| Host | User | Password |
+-----------+------+-------------------------------------------+
| localhost | luke | *55D9962586BE75F4B7D421E6655973DB07D6869F |
+-----------+------+-------------------------------------------+
1 row in set (0.001 sec)
The GRANT
statement assigns permissions. Table 18‑1 shows common forms.
Table 18-1 Common GRANT statement forms
Form | Purpose |
---|---|
GRANT <priv> ON db.table TO user@host | Grant specific privileges on a specific table |
GRANT <priv> ON db.* TO user@host | Grant privileges on all tables in a database |
GRANT <priv> ON *.* TO user@host | Grant privileges across all databases and tables |
GRANT priv1,priv2 ON db.* TO user@host | Grant multiple privileges at once |
GRANT ALL PRIVILEGES ON *.* TO user@host | Grant everything (use with care) |
As database root, I grant SELECT
, UPDATE
, DELETE
, and INSERT
on the mysql.user
table to luke@localhost
:
MariaDB [(none)]> exit
Bye
root@linuxprobe:~# mysql -u luke -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 10.11.9-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SHOW databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.001 sec)
MariaDB [(none)]> exit
Bye
I verify:
root@linuxprobe:~# mysql
MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> GRANT SELECT,UPDATE,DELETE,INSERT ON mysql.user TO luke@localhost;
Query OK, 0 rows affected (0.001 sec)
Now, when luke
logs in, they can see the mysql
database and the user
table (but not other tables they lack privileges for). When I need to remove privileges, REVOKE
mirrors GRANT
:
MariaDB [mysql]> SHOW GRANTS FOR luke@localhost;
+--------------------------------------------------------------------------------------+
| Grants for luke@localhost |
+--------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `luke`@`localhost` IDENTIFIED BY PASSWORD '*55D9962586BE75F4B7D421E6655973DB07D6869F' |
| GRANT SELECT, INSERT, UPDATE, DELETE ON `mysql`.`user` TO `luke`@`localhost` |
+--------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)
MariaDB [mysql]> exit
Bye
I check again:
root@linuxprobe:~# mysql -u luke -p
Enter password:
MariaDB [(none)]> SHOW databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.001 sec)
MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> SHOW tables;
+-----------------+
| Tables_in_mysql |
+-----------------+
| user |
+-----------------+
1 row in set (0.000 sec)
MariaDB [mysql]> exit
Bye
When a user is no longer needed, I drop it:
root@linuxprobe:~# mysql
MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> REVOKE SELECT,UPDATE,DELETE,INSERT ON mysql.user FROM luke@localhost;
Query OK, 0 rows affected (0.001 sec)
18.4 Creating databases and tables
A single database can contain many tables. Tables are the core structure that stores data. I design tables to fit my needs, then store data accordingly for easy maintenance later. Table 18‑2 lists commands used in this section.
Table 18-2 Commands for creating and inspecting databases and tables
Command | Purpose |
---|---|
CREATE DATABASE <name>; | Create a database |
USE <db>; | Switch to a database |
SHOW databases; | List databases |
SHOW tables; | List tables in the current database |
DESCRIBE <table>; | Show table structure |
SELECT * FROM <table>; | Query all rows from a table |
UPDATE <table> SET col=new WHERE col>value; | Update rows |
DELETE FROM <table> WHERE col=value; | Delete rows |
I create a database and confirm it appears:
MariaDB [mysql]> SHOW GRANTS FOR luke@localhost;
+-------------------------------------------------------------------------------------------------------------+
| Grants for luke@localhost |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `luke`@`localhost` IDENTIFIED BY PASSWORD '*55D9962586BE75F4B7D421E6655973DB07D6869F' |
+-------------------------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)
MariaDB and MySQL are relational database management systems (RDBMS). Conceptually, a relational database resembles a spreadsheet (Figure 18‑2): the header row names columns; columns group values of the same type; rows describe individual records; keys identify records uniquely.
Figure 18-2 Conceptual view of relational storage
I create a table named mybook
and initialize its structure with three columns: a character column name
of length 15; and two integer columns, price
and pages
.
MariaDB [mysql]> DROP user luke@localhost;
Query OK, 0 rows affected (0.001 sec)
18.5 Managing tables and data
I insert a row into mybook
using INSERT
, then query it with SELECT
. Use *
to select all columns; list specific column names to select only those.
MariaDB [(none)]> CREATE DATABASE linuxprobe;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> SHOW databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| linuxprobe |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.001 sec)
DBA work centers on four skills: create, read, update, delete (CRUD). I update the price, then query only selected columns:
MariaDB [(none)]> use linuxprobe;
Database changed
MariaDB [linuxprobe]> CREATE TABLE mybook (name char(15),price int,pages int);
Query OK, 0 rows affected (0.021 sec)
MariaDB [linuxprobe]> DESCRIBE mybook;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| name | char(15) | YES | | NULL | |
| price | int(11) | YES | | NULL | |
| pages | int(11) | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.001 sec)
I update a specific row using WHERE
. First, I add two more rows:
MariaDB [linuxprobe]> INSERT INTO mybook(name,price,pages) VALUES('linuxprobe','60', '518');
Query OK, 1 row affected (0.001 sec)
MariaDB [linuxprobe]> SELECT * from mybook;
+------------+-------+-------+
| name | price | pages |
+------------+-------+-------+
| linuxprobe | 60 | 518 |
+------------+-------+-------+
1 row in set (0.001 sec)
Then I change only linuxcool
to 60:
MariaDB [linuxprobe]> UPDATE mybook SET price=55 ;
Query OK, 1 row affected (0.001 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [linuxprobe]> SELECT name,price FROM mybook;
+------------+-------+
| name | price |
+------------+-------+
| linuxprobe | 55 |
+------------+-------+
1 row in set (0.001 sec)
I delete rows with DELETE
. The following removes all rows from mybook
:
MariaDB [linuxprobe]> INSERT INTO mybook(name,price,pages) VALUES('linuxcool','85', '300');
Query OK, 1 row affected (0.001 sec)
MariaDB [linuxprobe]> INSERT INTO mybook(name,price,pages) VALUES('linuxdown','105', '500');
Query OK, 1 row affected (0.001 sec)
In real systems, tables will hold thousands of rows. I insert four rows to practice conditional queries:
MariaDB [linuxprobe]> UPDATE mybook SET price=60 where name='linuxcool';
Query OK, 1 row affected (0.001 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [linuxprobe]> select * from mybook;
+------------+-------+-------+
| name | price | pages |
+------------+-------+-------+
| linuxprobe | 55 | 518 |
| linuxcool | 60 | 300 |
| linuxdown | 105 | 500 |
+------------+-------+-------+
3 rows in set (0.001 sec)
I use WHERE
to filter. Table 18‑3 lists common operators.
Table 18-3 Common operators in the WHERE clause
Operator | Meaning |
---|---|
= | Equal to |
<> or != | Not equal to |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
BETWEEN | Within a range |
LIKE | Pattern match (fuzzy match) |
IN | One of a set of values |
Examples:
MariaDB [linuxprobe]> DELETE FROM mybook;
Query OK, 3 rows affected (0.001 sec)
MariaDB [linuxprobe]> SELECT * FROM mybook;
Empty set (0.001 sec)
I combine conditions with AND
to narrow results:
MariaDB [linuxprobe]> INSERT INTO mybook(name,price,pages) VALUES('linuxprobe1','30','518');
Query OK, 1 row affected (0.001 sec)
MariaDB [linuxprobe]> INSERT INTO mybook(name,price,pages) VALUES('linuxprobe2','50','518');
Query OK, 1 row affected (0.001 sec)
MariaDB [linuxprobe]> INSERT INTO mybook(name,price,pages) VALUES('linuxprobe3','80','518');
Query OK, 1 row affected (0.001 sec)
MariaDB [linuxprobe]> INSERT INTO mybook(name,price,pages) VALUES('linuxprobe4','100','518');
Query OK, 1 row affected (0.001 sec)
18.6 Backing up and restoring databases
Because my focus is Linux operations, I won’t go deeply into DBA topics here. The basics above are enough for daily work. One essential skill you must know, however, is backup and restore.
Use mysqldump
to back up a database. Its syntax is similar to the mysql
client: mysqldump [options] [database]
. With unix_socket
authentication locally, you can back up without a password.
I export the linuxprobe
database to the root user’s home directory:
MariaDB [linuxprobe]> SELECT * FROM mybook WHERE price>75;
+-------------+-------+-------+
| name | price | pages |
+-------------+-------+-------+
| linuxprobe3 | 80 | 518 |
| linuxprobe4 | 100 | 518 |
+-------------+-------+-------+
2 rows in set (0.001 sec)
MariaDB [linuxprobe]> SELECT * FROM mybook WHERE price!=80;
+-------------+-------+-------+
| name | price | pages |
+-------------+-------+-------+
| linuxprobe1 | 30 | 518 |
| linuxprobe2 | 50 | 518 |
| linuxprobe4 | 100 | 518 |
+-------------+-------+-------+
3 rows in set (0.001 sec)
Now I log in to MariaDB, drop the database (which also removes the table), and recreate the empty database:
MariaDB [linuxprobe]> SELECT * from mybook WHERE price=30 AND pages=518 ;
+-------------+-------+-------+
| name | price | pages |
+-------------+-------+-------+
| linuxprobe1 | 30 | 518 |
+-------------+-------+-------+
1 row in set (0.000 sec)
MariaDB [linuxprobe]> exit
Bye
Restore the backup by redirecting the dump file into mysql
:
root@linuxprobe:~# mysqldump linuxprobe > /root/linuxprobeDB.dump
I verify that the table is back:
root@linuxprobe:~# mysql
MariaDB [(none)]> DROP DATABASE linuxprobe;
Query OK, 1 row affected (0.106 sec)
MariaDB [(none)]> SHOW databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.001 sec)
MariaDB [(none)]> CREATE DATABASE linuxprobe;
Query OK, 1 row affected (0.001 sec)
Review Questions
-
Why does RHEL 10 choose MariaDB over MySQL?
Answer: Because MariaDB is maintained by the open‑source community and is not constrained by commercial patents. -
Which command initializes and secures a fresh MariaDB/MySQL installation?
Answer:mysql_secure_installation
—run it after each install. -
Which commands list existing databases and tables?
Answer:SHOW databases;
andSHOW tables;
. -
How do you switch to a specific database?
Answer:USE <database>;
-
Which statements grant and revoke privileges for a user?
Answer:GRANT
to assign privileges;REVOKE
to remove them. -
How do you delete the local user
luke
?
Answer:DROP USER luke@localhost;
-
How do you query only the
name
column from themybook
table?
Answer:SELECT name FROM mybook;
-
How do you list books in
mybook
with price greater than 75?
Answer:SELECT * FROM mybook WHERE price>75;
-
How do you export the
linuxprobe
database to a backup file in root’s home directory?
Answer:mysqldump -u root -p linuxprobe > /root/linuxprobeDB.dump
(locally, with unix_socket, the password may be omitted). -
How do you restore the above backup into the database?
Answer:mysql -u root -p linuxprobe < /root/linuxprobeDB.dump