[1] MariaDB – instalacja
22 stycznia 2022Zainstaluj MariaDB, aby skonfigurować serwer bazodanowy.
[1] Zainstaluj MariaDB
[root@vlsr01 ~]# dnf module list mariadb Ostatnio sprawdzono ważność metadanych: 0:51:01 temu w dniu sob, 22 sty 2022, 16:59:54. CentOS Stream 8 - AppStream Name Stream Profiles Summary mariadb 10.3 [d] client, galera, server [d] MariaDB Module mariadb 10.5 client, galera, server [d] MariaDB Module Wskazówka: [d]omyślne, [e]włączone, [x]wyłączone, [i]zainstalowane [root@vlsr01 ~]# dnf module reset mariadb [root@vlsr01 ~]# dnf module enable mariadb:10.5 Ostatnio sprawdzono ważność metadanych: 0:51:59 temu w dniu sob, 22 sty 2022, 16:59:54. Rozwiązano zależności. ============================================================================================ Pakiet Architektura Wersja Repozytorium Rozm. ============================================================================================ Włączanie strumieni modułów: mariadb 10.5 Podsumowanie transakcji ============================================================================================ W porządku? [t/N]: t Ukończono. [root@vlsr01 ~]# dnf module install mariadb:10.5 Ostatnio sprawdzono ważność metadanych: 0:52:49 temu w dniu sob, 22 sty 2022, 16:59:54. Rozwiązano zależności. ============================================================================================ Pakiet Arch. Wersja Repoz. Rozm. ============================================================================================ Instalowanie pakietów grupy/modułu: mariadb-server x86_64 3:10.5.9-1.module_el8.5.0+732+7afc82e7 appstream 18 M Instalowanie zależności: mariadb x86_64 3:10.5.9-1.module_el8.5.0+732+7afc82e7 appstream 6.2 M mariadb-common x86_64 3:10.5.9-1.module_el8.5.0+732+7afc82e7 appstream 68 k mariadb-connector-c x86_64 3.1.11-2.el8_3 appstream 200 k mariadb-connector-c-config noarch 3.1.11-2.el8_3 appstream 15 k mariadb-errmsg x86_64 3:10.5.9-1.module_el8.5.0+732+7afc82e7 appstream 239 k mysql-selinux noarch 1.0.2-4.el8 appstream 37 k perl-DBD-MySQL x86_64 4.046-3.module_el8.3.0+419+c2dec72b appstream 156 k perl-DBI x86_64 1.641-3.module_el8.3.0+413+9be2aeb5 appstream 740 k Instalowanie słabych zależności: mariadb-backup x86_64 3:10.5.9-1.module_el8.5.0+732+7afc82e7 appstream 6.8 M mariadb-gssapi-server x86_64 3:10.5.9-1.module_el8.5.0+732+7afc82e7 appstream 55 k mariadb-server-utils x86_64 3:10.5.9-1.module_el8.5.0+732+7afc82e7 appstream 1.2 M Instalowanie profili modułów: mariadb/server Włączanie strumieni modułów: perl-DBD-MySQL 4.046 perl-DBI 1.641 Podsumowanie transakcji ============================================================================================ Instalacja 12 pakietów Całkowity rozmiar pobierania: 34 M Rozmiar po zainstalowaniu: 168 M . . . . . [root@vlsr01 ~]# mcedit /etc/my.cnf.d/charset.cnf #stwórz nowy #ustaw domyślny system kodowania znakow #jeśli nie ustawisz domyślnym będzie [latin1] #dla znaków 4 bajtowych UTF-8, ustaw [utf8mb4] [mysqld] character-set-server = utf8mb4 [client] default-character-set = utf8mb4 [root@vlsr01 ~]# systemctl enable --now mariadb
[2] Jeżeli Firewalld jest uruchomiony zezwol na dostęp do serwera bazodanowego MariaDB ze zdalnych hostów, MariaDB korzysta z [3305/tcp].
[root@vlsr01 ~]# firewall-cmd --add-service=mysql --permanent success [root@vlsr01 ~]# firewall-cmd --reload Success
[3] Ustawienia początkowe dla MariaDB.
[root@vlsr01 ~]# 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 haven't set the root password yet, you should just press enter here. Enter current password for root (enter for none): #naciśnij [ENTER] OK, successfully used password, moving on... Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have your root account protected, so you can safely answer 'n'. #logowanie i autoryzacja za pomocą kont systemowych Switch to unix_socket authentication [Y/n] y Enabled successfully! Reloading privilege tables.. ... Success! You already have your root account protected, so you can safely answer 'n'. #zmiana hasla root’a [tego z bazy danych MariaDB] Change the root password? [Y/n] n ... skipping. 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. #usunięcie użytkownika anonimowego 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. #zakaz zdalnego logowania root’a 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. # usunięcie bazy [test] 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. #przeładowanie uprawnień 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! #podłączamy/logujemy się do MariaDB jako root [root@vlsr01 ~]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 27 Server version: 10.5.9-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> #pokaż listę użytkownikow MariaDB [(none)]> select user,host,password from mysql.user; +-------------+-----------+-------------------------------------------+ | User | Host | Password | +-------------+-----------+-------------------------------------------+ | mariadb.sys | localhost | | | root | localhost | *390E65A6C016941655A9308F521B5F7E02584A7E | | mysql | localhost | invalid | +-------------+-----------+-------------------------------------------+ rows in set (0.001 sec) #pokaż istniejące bazy MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.001 sec) #stwórz testową bazę danych MariaDB [(none)]> create database testowa_baza; Query OK, 1 row affected (0.000 sec) #stworz testową tabelę w testowej bazie MariaDB [(none)]> create table testowa_baza.testowa_tabela (id int, name varchar(50), address Query OK, 0 rows affected (0.020 sec) #wstaw dane do tabeli MariaDB [(none)]> insert into testowa_baza.testowa_tabela(id, name, address) values("001", "User01", "Rybnik"); Query OK, 1 row affected (0.001 sec) #pokaż testową tabelę MariaDB [(none)]> select * from testowa_baza.testowa_tabela; +----+--------+---------+ | id | name | address | +----+--------+---------+ | 1 | User01 | Rybnik | +----+--------+---------+ 1 row in set (0.000 sec) #skasuj testową bazę MariaDB [(none)]> drop database testowa_baza; Query OK, 1 row affected (0.003 sec)