Mysql – одна из самых популярных и широко используемых в мире систем управления реляционными базами данных (РСУБД). Разработанная в 1995 году компанией MySQL AB, в настоящее время она находится под эгидой корпорации Oracle. MySQL известна своими возможностями эффективного управления данными, гибкостью и совместимостью с различными платформами и языками программирования. В этой статье мы расскажем вам, как установить Сервер MySQL на AlmaLinux 10.
Необходимые условия
Условные обозначения
– given commands should be executed with root privileges either directly as a root user or by use of sudo command – given commands should be executed as a regular user
Самый простой и быстрый способ установить сервер MySQL на AlmaLinux 10 – из репозитория. Выполните приведенную ниже команду.
dnf install mysql-server
Вы увидите следующее сообщение:
Last metadata expiration check: 2:16:01 ago on Mon Mar 31 21:44:11 2025. Dependencies resolved. ========================================================================================================================================================================== Package Architecture Version Repository Size ========================================================================================================================================================================== Installing: mysql-server x86_64_v2 8.4.2-4.el10 appstream 18 M Installing dependencies: checkpolicy x86_64_v2 3.7-1.el10 appstream 353 k libaio x86_64_v2 0.3.111-20.el10 baseos 23 k libtirpc x86_64_v2 1.3.5-0.el10 baseos 94 k mariadb-connector-c-config noarch 3.4.1-1.el10 baseos 8.6 k mecab x86_64_v2 0.996-8.el10 appstream 360 k mysql x86_64_v2 8.4.2-4.el10 appstream 2.5 M mysql-common noarch 8.4.2-4.el10 appstream 79 k mysql-errmsg noarch 8.4.2-4.el10 appstream 528 k mysql-selinux noarch 1.0.10-4.el10 appstream 36 k policycoreutils-python-utils noarch 3.7-2.el10 appstream 52 k protobuf-lite x86_64_v2 3.19.6-10.el10 appstream 256 k python3-audit x86_64_v2 4.0-9.el10 appstream 67 k python3-distro noarch 1.9.0-4.el10 appstream 50 k python3-libsemanage x86_64_v2 3.7-1.el10 appstream 81 k python3-policycoreutils noarch 3.7-2.el10 appstream 2.2 M python3-setools x86_64_v2 4.5.1-3.el10 baseos 741 k python3-setuptools noarch 69.0.3-5.el10 baseos 1.6 M Transaction Summary ========================================================================================================================================================================== Install 18 Packages Total download size: 27 M Installed size: 183 M Is this ok [y/N]:
Нажмите Y, чтобы продолжить установку, и дождитесь ее завершения.
Через несколько минут сервер MySQL будет установлен. На этом этапе нам нужно запустить его, так как он не запускается автоматически при установке.
systemctl start mysqld
Теперь он должен быть запущен, мы можем проверить это с помощью данной команды:
systemctl status mysqld
Вы получите следующее сообщение:
systemctl status mysqld
● mysqld.service - MySQL 8.4 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; preset: disabled)
Active: active (running) since Tue 2025-04-01 00:03:07 CDT; 13s ago
Invocation: 2c73a87b3caa4c7aa5aa577954df84c2
Process: 3756 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Process: 3778 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
Main PID: 3854 (mysqld)
Status: "Server is operational"
Tasks: 35 (limit: 23175)
Memory: 448.4M (peak: 461.1M)
CPU: 7.356s
CGroup: /system.slice/mysqld.service
└─3854 /usr/libexec/mysqld --basedir=/usr
Apr 01 00:02:55 rh.aroel.net systemd[1]: Starting mysqld.service - MySQL 8.4 database server...
Apr 01 00:02:55 rh.aroel.net mysql-prepare-db-dir[3778]: Initializing MySQL database
Apr 01 00:03:07 rh.aroel.net systemd[1]: Started mysqld.service - MySQL 8.4 database server.
Как видно выше, Active: active (running) означает, что сервер MySQL запущен.
Если вы снова увидите статус, особенно в части Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; preset: disabled). Это означает, что MySQL не будет автоматически запускаться при перезагрузке сервера. Чтобы изменить это, мы можем выполнить следующую команду:
systemctl enable mysqld
Теперь systemctl включил службу MySQL. Она будет автоматически запускаться при каждой перезагрузке сервера.
Теперь мы можем попробовать войти в оболочку MySQL.
mysql
После выполнения команды вы увидите следующее:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 55 Server version: 8.4.2 Source distribution Copyright (c) 2000, 2024, 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>
Теперь вы можете начать работать в оболочке MySQL. Вы можете набрать \q и нажать ENTER, чтобы выйти из оболочки.
Как видно, мы можем войти в оболочку MySQL без пароля как пользователь root. Чтобы защитить MySQL, мы можем выполнить эту команду:
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? Press y|Y for Yes, any other key for No:
Нажмите Y, а затем ENTER.
После этого вы увидите следующее сообщение:
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 Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
Введите 2, если вам нужен самый надежный пароль.
Затем скрипт попросит вас ввести новый пароль root. Убедитесь, что это надежный пароль, содержащий не менее 8 цифровых, смешанных и специальных символов.
New password: Re-enter new password: Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :
Выберите Y, а затем ENTER
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. Remove anonymous users? (Press y|Y for Yes, any other key for No) :
Нажмите Y, а затем ENTER
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? (Press y|Y for Yes, any other key for No) :
Снова нажмите Y, а затем ENTER
Remove test database and access to it? (Press y|Y for Yes, any other key for No) :
Нажмите Y, а затем ENTER еще раз
- 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? (Press y|Y for Yes, any other key for No) :
Наконец, нажмите Y, а затем ENTER в последний раз.
Success. All done!
Вот и все! Вы успешно установили MySQL Server на AlmaLinux 10 и закрепили установку.
Поздравляем! Вы следовали этой статье и теперь можете установить MySQL на AlmaLinux 10.




Комментарии (0)