MariaDB

From Bauman National Library
This page was last modified on 22 June 2016, at 15:25.
MariaDB
Mariadb.png
Developer(s)

MariaDB Corporation Ab,

MariaDB Foundation
Initial release January 22, 2009 (2009-01-22)
Repository {{#property:P1324}}
Written in C, C++, Perl, Bash
Operating system Cross-platform
Type RDBMS (embedded)
License GNU GPL[1]
Website www.mariadb.org

MariaDB is an enhanced, drop-in replacement for MySQL and is available under the terms of the GPL v2 license. It's developed by the MariaDB community with the MariaDB Foundation as its main steward.

General

MariaDB is written in C, C++, Perl, Bash. MariaDB is cross-platform (Unix, Windows, Solaris, Linux, OS X, BSD). Current stable version is 10.1.13

Security

Security is a particular focus for the MariaDB developers. The project maintains its own set security patches on top of MySQL's. For each MariaDB release the developers also merge in all of MySQL's security patches and enhance them if necessary. When critical security issues are discovered the developers immediately prepare and distribute a new release of MariaDB to get the fix out as quickly as possible.

Many of the security issues found in MySQL and MariaDB have been found and reported by the MariaDB team. The MariaDB team works closely with http://cve.mitre.org/ to ensure all security issues are promptly reported and explained in sufficient detail. The security details are typically released after fixed MariaDB and MySQL versions have been published.

Compatibility

MariaDB is kept up to date with the latest MySQL release from the same branch and in most respects MariaDB will work exactly as MySQL. All commands, interfaces, libraries and APIs that exist in MySQL also exist in MariaDB. There is no need to convert databases to switch to MariaDB. MariaDB is a true drop in replacement of MySQL! Additionally, MariaDB has many nice new features that you can take advantage of.

MariaDB Foundation

The MariaDB Foundation ensures that there is not just one person or one company driving MariaDB/MySQL development. It is the custodian of the MariaDB code and guardian of the MariaDB community.

The MariaDB Foundation is the owner of the main MariaDB server project and owns mariadb.org. This ensures that the official MariaDB development tree will always be open for the MariaDB developer community.

Использование

Установка

MySQL и MariaDB используют один и тот же синтаксис команд, поэтому любая из этих систем поддерживает команды из примеров. Для установки MySQL выполните команду: MySQL and MarisDB use single syntax. Hence, following commands can be used with either DB.

sudo apt-get install mysql-server

Commands to install MariaDB on Ubuntu 12.04:

sudo apt-get update
sudo apt-get install python-software-properties
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://repo.maxindo.net.id/mariadb/repo/5.5/ubuntu precise main'
sudo apt-get update
sudo apt-get install mariadb-server

Creating DB

Create DB and enter it:

mariadb -u root -p

Creating DB playground:

CREATE DATABASE playground;

Enter DB:

USE playground;

Creating tables

Syntax:

CREATE TABLE [IF NOT EXISTS] name_of_table (list_of_table_columns) [engine=database_engine]

Parts in Template:And can be dismissed. IF NOT EXISTS points out that table will be created if only it is not in DB already. Otherwise error will occur. Участки в скобках ([ и ]) можно опускать. Фраза IF NOT EXISTS указывает на то, что таблица будет создана только в том случае, если она отсутствует в БД. В противном случае возникнет ошибка.

CREATE TABLE IF NOT EXISTS equipment (
   equip_id int(5) NOT NULL AUTO_INCREMENT,
   type varchar(50) DEFAULT NULL,
   install_date DATE DEFAULT NULL,
   color varchar(20) DEFAULT NULL,
   working bool DEFAULT NULL,
   location varchar(250) DEFAULT NULL,
   PRIMARY KEY(equip_id)
);
Query OK, 0 rows affected (0.03 sec)

Data input

Input syntax:

INSERT INTO table_name (field1, field2, ...) VALUES (value1, value2, ...);

All string value should be in quotes.

INSERT INTO equipment (type, install_date, color, working, location)
VALUES
("Slide", Now(), "blue", 1, "Southwest Corner");

We used in-built function now(), that return current date. To read all data we need to send request. * is a special symbol, that indicates selecting all rows:

SELECT * FROM equipment;
+----------+-------+--------------+-------+---------+------------------+
| equip_id | type  | install_date | color | working | location         |
+----------+-------+--------------+-------+---------+------------------+
|        1 | Slide | 2013-07-26   | blue  |       1 | Southwest Corner |
+----------+-------+--------------+-------+---------+------------------+
1 row in set (0.00 sec)

Add another row:

INSERT INTO equipment (type, install_date, color, working, location)
VALUES
("Swing", Now(), "green", 1, "Northwest Corner");

Check it:

SELECT * FROM equipment;
+----------+-------+--------------+-------+---------+------------------+
| equip_id | type  | install_date | color | working | location         |
+----------+-------+--------------+-------+---------+------------------+
|        1 | Slide | 2013-07-26   | blue  |       1 | Southwest Corner |
|        2 | Swing | 2013-07-26   | green |       1 | Northwest Corner |
+----------+-------+--------------+-------+---------+------------------+
2 rows in set (0.00 sec)

Deleting tables

For deleting should be used this command:

DROP TABLE table_name;

Be careful, this can't be undone

SHOW tables;
+----------------------+
| Tables_in_playground |
+----------------------+
| equipment            |
+----------------------+
1 row in set (0.00 sec)

Delete our only table:

DROP TABLE equipment;

Check it:

SHOW tables;
Empty set (0.00 sec)

Links

References

Cite error: Invalid <references> tag; parameter "group" is allowed only.

Use <references />, or <references group="..." />
  1. "GNU GPL".