[1] MySQL – Instalacja
27 stycznia 2022Zainstalujemy teraz bazę danych MySQL.
[1] Zainstaluj i uruchom MySQL.
[root@vlsr01 ~]# dnf module install --allowerasing mysql:8.0 [root@vlsr01 ~]# mcedit /etc/my.cnf.d/charset.cnf #stwórz nowy [mysqld] character-set-server = utf8mb4 [client] default-character-set = utf8mb4 [root@vlsr01 ~]# systemctl enable --now mysqld
[2] Jeśli Firewalld jest uruchomiony to zezwól na ruch na porcie [3306/tcp].
[root@vlsr01 ~]# firewall-cmd --add-service=mysql --permanent [root@vlsr01 ~]# firewall-cmd –reload
[3] Ustawienia początkowe dla MySQL.
[root@vlsr01 ~]# mysql_secure_installation Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component? #włączenie walidacji haseł Press y|Y for Yes, any other key for No: y There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file #wybierz siłę hasła Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 Please set the password for root here. #ustaw hasło root New password: #wpisz hasło Re-enter new password: #wpisz hasło ponownie #potwierdź wprowadzenie i użycie hasła Estimated strength of the password: 50 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL 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 anonimowego użytkownika Remove anonymous users? (Press y|Y for Yes, any other key for No) : 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. #zabronienie root’owi zdalne logowanie Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Success. By default, MySQL 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 testowej Remove test database and access to it? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y Success. All done! [root@vlsr01 ~]# mysql -u root -p Enter password: #wpisz hasło Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.26 Source distribution Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select user,host from mysql.user; +------------------+-----------+ | user | host | +------------------+-----------+ | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +------------------+-----------+ 4 rows in set (0,00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0,00 sec) mysql> create database test_database; Query OK, 1 row affected (0,01 sec) mysql> create table test_database.test_table (id int, name varchar(50), address varchar(50), primary key (id)); Query OK, 0 rows affected (0,16 sec) mysql> insert into test_database.test_table(id, name, address) values("001", "CentOS", "Rybnik"); Query OK, 1 row affected (0,00 sec) mysql> select * from test_database.test_table; +----+--------+-----------+ | id | name | address | +----+--------+-----------+ | 1 | CentOS | Rybnik | +----+--------+-----------+ 1 row in set (0,00 sec) mysql> drop database test_database; Query OK, 1 row affected (0,01 sec) mysql> exit Bye