Categories

[MariaDB] How to install MariaDB on Linux

You are here:
  • Main
  • MariaDB
  • [MariaDB] How to install MariaDB on Linux
< All Topics

ENVIRONMENT

  • Ubuntu 18.04.4 LTS
  • MariaDB 15.1

Today,
I’ll try to install Mariadb on my Ubuntu on VirtualBox.

You have to follow the following steps:

$ sudo apt update

$ sudo apt install mariadb-server

$ sudo systemctl status mariadb

$  mysql -V

After for securing MariaDB:

$  mysql_secure_installation

The script will prompt you to set up the root user password, to log in MariaDB server as the root user type:

$ mysql -u root -p

Below, I’ve run these commands to create DB and insert the test values:

CREATE DATABASE IF NOT EXISTS test;

USE test;

CREATE DATABASE IF NOT EXISTS test;

USE test;

CREATE TABLE IF NOT EXISTS books (
  BookID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
  Title VARCHAR(100) NOT NULL,
  SeriesID INT, AuthorID INT);

CREATE TABLE IF NOT EXISTS authors
(id INT NOT NULL PRIMARY KEY AUTO_INCREMENT);

CREATE TABLE IF NOT EXISTS series
(id INT NOT NULL PRIMARY KEY AUTO_INCREMENT);

INSERT INTO books (Title,SeriesID,AuthorID)
VALUES('La compagnia dell\'anello',1,1),
      ('Le due torri',1,1), ('Il ritorno del re',1,1),  <br>
     ('Lo Hobbit',0,1);
SELECT FOUND_ROWS();

Backing Up Everything

To export all of the databases in MariaDB using mysqldump, the following would be entered from the filesystem command-line:

mysqldump --user=admin_backup --password 
--lock-tables --all-databases > /data/backup/dbs.sql

Just One Database

mysqldump --user=admin_backup --password 
--lock-tables --databases db1 > /data/backup/db1.sql

Dumping Tables

mysqldump --user=admin_backup --password 
--lock-tables db1 table1 > /data/backup/db1_table1.sql
Table of Contents
Tags: