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

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

Ключ

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


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


Аннотация

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

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

  • версия 1:10.3.27-0+deb10u1 в базовом репозитории;
  • версия 1:10.3.29-0+deb10u1в расширенном репозитории;
  • на установочном диске СУБД MariaDB отсутствует.

Подробнее про структуру и использование репозиториев см. Репозитории Astra Linux Special Edition 1.7: особенности подключения и использования

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

  1. Подключить базовый или расширенный репозиторий (см. Репозитории Astra Linux Special Edition 1.7: особенности подключения и использования);
  2. Обновить список пакетов:

    Command
    sudo apt update


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

    Command
    sudo apt dist-upgrade


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

    Command
    apt policy mariadb-server


  5. Установить пакеты старшей доступной версии:

    Command
    sudo apt

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

sudo apt -y
  1. 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.
  1. или пакеты из базового репозитория:

    Command
    sudo apt install mariadb-server=1:10.3.27-0+deb10u1 mariadb-client=1:10.3.27-0+deb10u1


  2. Убедиться, что служба 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: 

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