Дерево страниц

Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.
Оглавление

https://computingforgeeks.com/how-to-install-mariadb-on-debian-10-buster/

Информация
titleДанная статья применима к:
Astra Linux Special Edition


Информация
titleДанная статья применима к:
  • Astra Linux Special Edition РУСБ.10015-01 (очередное обновление 1.7) с подключенным базовым и расширенным репозиториями
  • Astra Linux Special Edition РУСБ.10152-02 (очередное обновление 4.7) с подключенным базовым и расширенным репозиториями


Аннотация

Предупреждение
titleВнимание!

Программное обеспечение расширенного репозитория является сторонним по отношению к Astra Linux, не дорабатывается с точки зрения выполнения требований по безопасности информации и не проверяется при сертификации.
Подробнее см. Использование стороннего программного обеспечения в аттестованных информационных системах, функционирующих под управлением Astra Linux Special Edition.

При использовании программного обеспечения расширенного репозитория рекомендуется для дополнительной изоляции процессов осуществлять их запуск в изолированной программной среде (контейнере) [п. 7.2 РукКСЗ1]. При использовании для этих целей Docker-контейнеров их запуск целесообразно осуществлять от имени непривилегированного пользователя в rootless-режиме, а при включенном мандатном контроле целостности (МКЦ) с применением технологии запуска контейнеров на пониженном [п. 7.2.1] или выделенном [п. 7.2.7] уровне МКЦ.


Предупреждение
titleВнимание!

Не допускается одновременно использовать расширенный и основной/базовый репозитории из разных версий оперативных обновлений.

В данной статье представлена инструкция по установке и первичной настройке СУБД MariaDB в Astra Linux Special Edition x.7 с подключенным расширенным (extended) репозиторием. На момент написания статьи в Astra Linux Special Edition РУСБ.10015-01 (очередное обновление 1.7)

доступны следующие версии СУБД MariaDB:

Предупреждение
Установка полноценной СУБД MariaDB должна выполняться из расширенного репозитория. Подробнее про состояние, структуру и использование репозиториев см. Репозитории Astra Linux Special Edition x.7: структура, особенности подключения и использования.

Что такое СУБД MariaDВ

Раскрыть

Общая информация

MariaDB — ответвление от системы управления базами данных MySQL, разрабатываемое сообществом под лицензией GNU GPL. Причиной создания стала необходимость обеспечения свободного статуса СУБД, в противовес политике лицензирования MySQL компанией Oracle. MariaDB обеспечивает высокую совместимость с MySQL и точное соответствие с API и командами MySQL. В состав MariaDB включена подсистема хранения данных XtraDB для возможности замены InnoDB, как основной подсистемы хранения.

Оригинальная документация СУБД MariaDB

Оригинальная документация СУБД MariaDB доступна по ссылке: https://mariadb.org/documentation/


Установка пакетов

  1. Подключить репозитории:
    1. основной репозиторий и актуальное оперативное обновление основного репозитория;
    2. актуальное оперативное обновление базового репозитория;
    3. актуальное оперативное обновление расширенного репозитория, включая компонент astra-ce для обновлений ниже обновления БЮЛЛЕТЕНЬ № 2022-0819SE17 (оперативное обновление 1.7.2);

      Предупреждение
      Если в используемом обновлении ОС пакеты, находящихся в основном/базовом и в расширенном репозиториях, имеют одинаковые версии, то репозиторий, из которого необходимо установить пакет, должен быть указан в списке репозиториев первым.


  2. Обновить список пакетов:

    Command
    sudo apt update


  3. Опционально: установить актуальное обновление:

    Command
    sudo apt dist-upgrade


  4. Проверить доступные версии СУБД MariaDB:

    Command
    apt policy mariadb-server mariadb-client


  5. Установить пакеты:

    Command
    sudo apt install mariadb-server mariadb-client

    или установить пакеты с выбором нужной версии:

    Command
    sudo apt install mariadb-server=<номер_версии> mariadb-client=<номер_версии>


  6. Проверить установленную версию и убедиться, что она установлена из нужного репозитория:

    Command
    apt policy mariadb-server mariadb-client

    Пример вывода команды:

    Блок кода
    mariadb-server:
      Установлен: 1:10.3.34-0+deb10u1
      Кандидат:   1:10.3.34-0+deb10u1
      Таблица версий:
     *** 1:10.3.34-0+deb10u1 900
            900 https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-extended 1.7_x86-64/main amd64 Packages
            100 /var/lib/dpkg/status
         1:10.3.34-0+deb10u1 900
            900 https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-base 1.7_x86-64/main amd64 Packages

    строка 100 /var/lib/dpkg/status указывает репозиторий, из которого установлен пакет (в данном случае - интернет-репозиторий https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-extended).

  7. Убедиться, что служба mariadb запустилась:

    Command
    Titlesudo systemctl status mariadb

    ● mariadb.service - MariaDB 10.3.29 database server
       Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
       Active: active (running) since Mon 2021-09-13 10:30:19 MSK; 1min 9s ago
         Docs: man:mysqld(8)
               https://mariadb.com/kb/en/library/systemd/
     Main PID: 5380 (mysqld)
       Status: "Taking your SQL requests now..."
        Tasks: 31 (limit: 4637)
       Memory: 68.3M
       CGroup: /system.slice/mariadb.service
               └─5380 /usr/sbin/mysqld

    сен 13 10:30:20 se17 /etc/mysql/debian-start[5417]: performance_schema
    сен 13 10:30:20 se17 /etc/mysql/debian-start[5417]: Phase 6/7: Checking and upgrading tables
    сен 13 10:30:20 se17 /etc/mysql/debian-start[5417]: Running 'mysqlcheck' with connection argumen
    сен 13 10:30:20 se17 /etc/mysql/debian-start[5417]: # Connecting to localhost...
    сен 13 10:30:20 se17 /etc/mysql/debian-start[5417]: # Disconnecting from localhost...
    сен 13 10:30:20 se17 /etc/mysql/debian-start[5417]: Processing databases
    сен 13 10:30:20 se17 /etc/mysql/debian-start[5417]: information_schema
    сен 13 10:30:20 se17 /etc/mysql/debian-start[5417]: performance_schema
    сен 13 10:30:20 se17 /etc/mysql/debian-start[5417]: Phase 7/7: Running 'FLUSH PRIVILEGES'
    сен 13 10:30:20 se17 /etc/mysql/debian-start[5417]: OK


Первичная настройка СУБД

  1. Для выполнения первичной настройки СУБД выполнить команду:

    Command
    sudo mysql_secure_installation

    после чего в диалоге команды:

    1. На запрос пароля root ввести пустой пароль:

      Блок кода
      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
      you haven't set the root password yet, the password will be blank,
      so you should just press enter here.
      Enter current password for root (enter for none): 
      


    2. На вопрос "Set root password?" ответить Yes (Y):

      Блок кода
      OK, successfully used password, moving on...
      
      Setting the root password ensures that nobody can log into the MariaDB
      root user without the proper authorisation.
      
      Set root password? [Y/n] y


    3. Ввести и подтвердить пароль:

      Блок кода
      New password: 
      Re-enter new password: 
      Password updated successfully!
      Reloading privilege tables..
       ... Success!


    4. Удалить анонимных пользователей:

      Блок кода
      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!


    5. Запретить удаленный вход пользователя root:

      Блок кода
      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!



    6. Удалить тестовую базу данных:

      Блок кода
      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!



    7. Для того, чтобы сделанные изменения были применены немедленно, обновить таблицы привилегий:

      Блок кода
      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!


  2. Обновить настройки аутентификации, чтобы аутентификация пользователя root по паролю выполнялась как для обычных пользователей, для чего войти в сессию работы с СУБД выполнив команду:

    Command
    sudo mysql -u root

    и далее в сессии работы с СУБД выполнить команды:

    Блок кода
    UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';
    FLUSH PRIVILEGES;
    QUIT;


Первичное тестирование работоспособности СУБД

  1. Войти в сессию работы с СУБД выполнив команду:

    Command
    mysql -u root -p

    далее в сессии СУБД:

    1. Ввести пароль root:

      Блок кода
       Enter password:
       Welcome to the MariaDB monitor.  Commands end with ; or \g.
       Your MariaDB connection id is 67
       Server version: 

Аннотация

Setting strong root password
Removing anonymous users
Disabling remote login for root user.
Removing test database and access to it

Установка пакетов

sudo apt -y install mariadb-server mariadb-client

When prompted to set the root password, provide the password and confirm.
The version of MariaDB installed as default is 10.3. This can be confirmed with:

sudo systemctl status mariadb

sudo 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
 you haven't set the root password yet, the password will be blank,
 so you should just press enter here.
 Enter current password for root (enter for none): 
 OK, successfully used password, moving on…
 Setting the root password ensures that nobody can log into the MariaDB
 root user without the proper authorisation.
 Set 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!
Update authentication plugin to allow root password authentication as normal user.

sudo mysql -u root
UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';
FLUSH PRIVILEGES;
QUIT;
Test MariaDB database installation.

mysql -u root -p
 Enter password: 
 Welcome to the MariaDB monitor.  Commands end with ; or \g.
 Your MariaDB connection id is 67
 Server version:
    1. 10.3.13-MariaDB-1 Debian buildd-unstable

    1. 
       Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

    1. 
      Confirm version from MySQL CLI:
      


    2. Ввести команду SELECT VERSION(); которая выведет версию текущей СУБД:

      Блок кода
      MariaDB [(none)]> SELECT VERSION();

    1. 
       +-------------------+

    1. 
       | VERSION()         |

    1. 
       +-------------------+

    1. 
       | 10.3.13-MariaDB-1 |

    1. 
       +-------------------+

    1. 
       1 row in set (0.001 sec)


    2. Выйти из сессии СУБД:

      Блок кода
       MariaDB [(none)]>
QUITThat’s all. Enjoy running the MariaDB Database server on Debian 10 (Buster).
    1.  QUIT