Как установить последний MySQL 8.0 на RHEL / CentOS и Fedora

by itisgood

MySQL – это система управления реляционными базами данных с открытым исходным кодом (RDBMS), выпущенная в соответствии с GNU (General Public License).

Он используется для запуска нескольких баз данных на любом отдельном сервере, предоставляя многопользовательский доступ к каждой созданной базе данных.

В этой статье мы рассмотрим процесс установки и обновления последней версии MySQL 8.0 на RHEL / CentOS 7/6 / и Fedora 28-26 с использованием репозитория MySQL Yum через утилиту YUM.

Шаг 1. Добавление репозитория MySQL Yum

1. Мы будем использовать официальный репозиторий программного обеспечения MySQL Yum, который предоставит пакеты RPM для установки последней версии сервера MySQL, клиента, MySQL Utilities, MySQL Workbench, Connector / ODBC и Connector / Python для RHEL / CentOS 7/6 / и Fedora 28-26.

Важно: эти инструкции работают только с новой установкой MySQL на сервере, если MySQL уже установлен с использованием пакета RPM, распределенного сторонней стороной, тогда я рекомендую вам обновить или заменить установленный пакет MySQL с помощью репозитория MySQL Yum ” ,

Перед обновлением или заменой старого пакета MySQL не забудьте взять все важные файлы резервного копирования и настройки баз данных.

2. Теперь загрузите и добавьте следующий репозиторий MySQL Yum в список репозитория вашей системы Linux, чтобы установить последнюю версию MySQL (т. е. 8.0, выпущенную 27 июля 2018 года).

--------------- На RHEL/CentOS 7 ---------------
# wget https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
--------------- На RHEL/CentOS 6 ---------------
# wget https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm
--------------- На Fedora 28 ---------------
# wget https://dev.mysql.com/get/mysql80-community-release-fc28-1.noarch.rpm
--------------- На Fedora 27 ---------------
# wget https://dev.mysql.com/get/mysql80-community-release-fc27-1.noarch.rpm
--------------- На Fedora 26 ---------------
# wget https://dev.mysql.com/get/mysql80-community-release-fc26-1.noarch.rpm

3. После загрузки пакета для вашей платформы Linux теперь установите загруженный пакет с помощью следующей команды:

--------------- На RHEL/CentOS 7 ---------------
# yum localinstall mysql80-community-release-el7-1.noarch.rpm
--------------- На RHEL/CentOS 6 ---------------
# yum localinstall mysql80-community-release-el6-1.noarch.rpm
--------------- На Fedora 28 ---------------
# dnf localinstall mysql80-community-release-fc28-1.noarch.rpm
--------------- На Fedora 27 ---------------
# dnf localinstall mysql80-community-release-fc27-1.noarch.rpm
--------------- На Fedora 26 ---------------
# yum localinstall mysql80-community-release-fc26-1.noarch.rpm

Вышеупомянутая команда установки добавляет репозиторий MySQL Yum в список репозитория системы и загружает ключ GnuPG для проверки целостности пакетов.

4. Вы можете проверить, что репозиторий MySQL Yum был успешно добавлен, используя следующую команду:

# yum repolist enabled | grep "mysql.*-community.*"
# dnf repolist enabled | grep "mysql.*-community.*"      [На Fedora]

Шаг 2. Установка последней версии MySQL.

5. Установите последнюю версию MySQL (в настоящее время 8.0), используя следующую команду.

# yum install mysql-community-server
# dnf install mysql-community-server      [На Fedora]

Вышеупомянутая команда устанавливает все необходимые пакеты для MySQL-сервера: mysql-community-server, mysql-community-client, mysql-community-common и mysql-community-libs.

Шаг 3: Установка MySQL  Release Series

6. Вы также можете установить другую версию MySQL, используя разные субрепозитории MySQL Community Server.

Суб-репозиторий для последней серии MySQL (в настоящее время MySQL 8.0) активируется по умолчанию, а субрепозитории для всех других версий (например, MySQL 5.x) дезактивируются.

Чтобы установить определенную версию из определенного субрепозитория, вы можете использовать опции –enable или –disable, используя yum-config-manager или dnf config-manager, как показано тут:

# yum-config-manager --disable mysql57-community
# yum-config-manager --enable mysql56-community
------------------ Fedora  ------------------
# dnf config-manager --disable mysql57-community
# dnf config-manager --enable mysql56-community

Шаг 4: Запуск сервера MySQL7.

7. После успешной установки MySQL пришло время запустить сервер MySQL с помощью следующей команды:

# service mysqld start

Вы можете проверить статус сервера MySQL с помощью следующей команды:

# service mysqld status

Вот пример вывода MySQL:

Redirecting to /bin/systemctl status  mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: active (running) since Thu 2015-10-29 05:15:19 EDT; 4min 5s ago
Process: 5314 ExecStart=/usr/sbin/mysqld --daemonize $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 5298 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 5317 (mysqld)
CGroup: /system.slice/mysqld.service
└─5317 /usr/sbin/mysqld --daemonize
Oct 29 05:15:19 localhost.localdomain systemd[1]: Started MySQL Server.

8. Теперь, наконец, проверьте установленную версию MySQL, используя следующую команду:

# mysql --version
mysql  Ver 8.0.12 for Linux on x86_64 (MySQL Community Server - GPL)

Шаг 5. Обеспечение безопасности установки MySQL.

9. Команда mysql_secure_installation позволяет защитить вашу установку MySQL, выполнив важные настройки, такие как установка пароля root, удаление анонимных пользователей, удаление логина root  и т. д.

Примечание. MySQL версии 8.0 или выше создает временный случайный пароль в /var/log/mysqld.log после установки.

Используйте команду ниже, чтобы увидеть пароль перед запуском команды mysql secure.

# grep 'temporary password' /var/log/mysqld.log

После того, как вы узнаете пароль, вы можете запустить следующую команду для установки MySQL.

# mysql_secure_installation

Примечание. Введите новый пароль root – ваш временный пароль из файла /var/log/mysqld.log.

Узнать больше о безопасности MySQL

Пример вывода:

Securing the MySQL server deployment.
Enter password for user root: Enter New Root Password
VALIDATE PASSWORD PLUGIN 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 plugin?
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
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.
Estimated strength of the password: 50 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password: Set New MySQL Password
Re-enter new password: Re-enter New MySQL 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
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
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? (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.
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
Success.
All done!

Шаг 6: Подключение к серверу MySQL

10. Подключение к вновь установленному серверу MySQL путем предоставления имени пользователя и пароля.

# mysql -u root -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.1 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
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>

Шаг 7: Обновление MySQL с помощью Yum

11. Помимо новой установки, вы также можете делать обновления для продуктов и компонентов MySQL с помощью следующей команды:

# yum update mysql-server
# dnf update mysql-server       [На Fedora ]

 

You may also like

Leave a Comment