Part 8: MariaDB

See all of the guides.

General information

MariaDB kinda equals mysql. MariaDB is a community brand that was created when Oracle acquired Sun.

Installing

yum install -y mariadb mariadb-server

Start and enable services

systemctl start mariadb

systemctl enable mariadb

Secure the install

mysql_secure_installation

mysql_secure_installation

Login to verify

mysql login

Basic Operations

Databases

Create a new database:

create database dbname

Enter the new database:

use dbname

Create and show databases

Tables

Create a table

create table tbl_name(column1 type, column2 type, column3 type);

Example:

CREATE table movies(id int, year int, name varchar(50));

Add data

insert into tblname (column1,column2,column3) VALUES(2222,111,"data") ;

INSERT into movies (id,year,name) VALUES(1,2001,"That One") ;

Update data

UPDATE movies SET Name = 'Real Title', year= '2019' WHERE id = 1;

Show data.

select * from movies;

Users

Create a user:

CREATE USER lisa@'%' IDENTIFIED BY 'secret';

Permissions

Grants permissions to a user.

GRANT SELECT,INSERT,UPDATE,DELETE ON videos.* TO 'lisa'@'localhost';

GRANT database format is <database.tablename> TO 'user'@'host'

Backup / Restore

Logical Backups:

mysqldump -uroot -p videos > output-file.sql

Restore

mysqldump -uroot -p < output-file.sql