MySQL — одна из самых популярных и широко используемых в мире систем управления реляционными базами данных (RDBMS). Разработанное в 1995 году компанией MySQL AB программное обеспечение в настоящее время находится под эгидой корпорации Oracle. MySQL известна своими эффективными возможностями управления данными, гибкостью и совместимостью с различными платформами и языками программирования. В этой статье вы узнаете, как установить сервер MySQL на AlmaLinux 10.
Предварительные условия
- Сервер с AlmaLinux 10
- ROOT-доступ по SSH или обычный системный пользователь с привилегиями sudo
Условности
# — указанные команды должны выполняться с правами суперпользователя либо напрямую от имени пользователя root, либо с помощью команды sudo $ — указанные команды должны выполняться от имени обычного пользователя
Самый простой и быстрый способ установить сервер 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
Вы получите результат, подобный этому:
[root@rh ~]# 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.
Как видно выше, «Активно: активно (работает)» означает, что сервер MySQL сейчас работает.
Если вы снова видите статус, особенно в части «Загружено: загружено (/usr/lib/systemd/system/mysqld.service; отключено; предустановлено: отключено)», это означает, что MySQL не будет автоматически запускаться при перезагрузке сервера. Чтобы изменить это, мы можем выполнить следующую команду:
# systemctl enable mysqld
Теперь служба systemctl включила службу MySQL. Она будет автоматически запускаться при каждой перезагрузке сервера.
Теперь мы можем попробовать войти в MySQL shell.
# 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 # mysql_secure_installation
Этот скрипт предложит вам задать несколько вопросов.
[root@rh ~]# 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, если вам нужен самый надежный пароль.
Затем скрипт попросит вас ввести новый пароль администратора. Убедитесь, что это надёжный пароль, содержащий не менее 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, затем ВВЕДИТЕ
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, затем ВВЕДИТЕ еще раз
- 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.
Если вам понравилась эта статья, пожалуйста, поделитесь ею со своими друзьями или оставьте комментарий ниже.