Как установить MySQL 8.0 на Fedora 31/30/29

Как установить MySQL 8.0 на Fedora 31/30/29

 

В этом руководстве мы расскажем, как установить MySQL 8.0 на Fedora 31 / Fedora 30 / Fedora 29 Server или на рабочую станцию. Если у вас старая версия MySQL Server (например, 5.7), вам может потребоваться выполнить обновление на месте или сбросить все данные, обновить пакеты и повторно импортировать все данные базы данных в новую установленную MySQL 8.0.

Наше недавнее руководство по установке MySQL 8.0 было для Ubuntu:  Как установить MySQL 8.0 в Ubuntu . Версия MySQL, доступная через хранилище Fedora Modular, — MySQL 5.7.

Полный комплект стека LAMP в Fedora можно найти в разделе Как установить стек LAMP в Fedora.

Шаг 1: Добавьте репозиторий сообщества MySQL 8.0

Чтобы установить MySQL 8.0 на Fedora 31/30/29, вам нужно добавить репозиторий сообщества MySQL 8.0:

Добавить репозиторий MySQL 8.0 в Fedora 31

sudo dnf -y install https://repo.mysql.com//mysql80-community-release-fc31-1.noarch.rpm

Добавить репозиторий MySQL 8.0 в Fedora 30

Запустите команды.

sudo dnf -y install https://repo.mysql.com//mysql80-community-release-fc30-1.noarch.rpm

Добавить репозиторий MySQL 8.0 в Fedora 29

Запустите следующую команду на своем терминале Fedora 29:

sudo dnf -y install https://repo.mysql.com//mysql80-community-release-fc29-2.noarch.rpm

Это запишет файл репозитория в /etc/yum.repos.d/mysql-community.repo

Шаг 2: Установите MySQL Server 8.0 на Fedora 31/30/29

После того, как вы добавили репозиторий и подтвердили его включение, перейдите к установке MySQL 8.0 на Fedora 31/30/29, выполнив:

sudo dnf -y install mysql-community-server

После установки информацию о пакете можно увидеть из:

$ dnf info mysql-community-server
Last metadata expiration check: 0:40:41 ago on Sun 04 Nov 2018 09:55:41 AM UTC.
Installed Packages
Name         : mysql-community-server
Version      : 8.0.13
Release      : 1.fc29
Arch         : x86_64
Size         : 1.8 G
Source       : mysql-community-8.0.13-1.fc29.src.rpm
Repo         : @System
From repo    : mysql80-community
Summary      : A very fast and reliable SQL database server
URL          : http://www.mysql.com/
License      : Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Under GPLv2 license as shown in the Description field.
Description  : The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
             : and robust SQL (Structured Query Language) database server. MySQL Server
             : is intended for mission-critical, heavy-load production systems as well
             : as for embedding into mass-deployed software. MySQL is a trademark of
             : Oracle and/or its affiliates
             : 
             : The MySQL software has Dual Licensing, which means you can use the MySQL
             : software free of charge under the GNU General Public License
             : (http://www.gnu.org/licenses/). You can also purchase commercial MySQL
             : licenses from Oracle and/or its affiliates if you do not wish to be bound by the terms of
             : the GPL. See the chapter "Licensing and Support" in the manual for
             : further info.
             : 
             : The MySQL web site (http://www.mysql.com/) provides the latest news and
             : information about the MySQL software.  Also please see the documentation
             : and the manual for more information.
             : 
             : This package includes the MySQL server binary as well as related utilities
             : to run and administer a MySQL server.

Шаг 3: Настройте сервер MySQL

После установки MySQL 8.0 на Fedora 31/30/29 вам необходимо выполнить начальную настройку для ее защиты.

1.Запустите и включите mysqld сервис

sudo systemctl start mysqld.service
sudo systemctl enable mysqld.service

2. Скопируйте сгенерированный случайный пароль для пользователя root

grep 'A temporary password' /var/log/mysqld.log |tail -1

Запомните напечатанный пароль:

A temporary password is generated for [email protected]: 1ph/axo>vJe;

3. Запустите MySQL Secure Installation для изменения пароля root, удаленного запрета входа в систему root, удаления анонимных пользователей и удаления тестовой базы данных.

$ mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:

Авторизуйтесь с помощью вашего сгенерированного временного пароля. Затем настройте установку MySQL 8.0, как показано ниже:

Change the password for root ? ((Press y|Y for Yes, any other key for No) : Yes

New password: 
Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?: Yes

Remove anonymous users?: Yes
Success.

Disallow root login remotely? : Yes
Success.

Remove test database and access to it? : Yes
 - Dropping test database...
Success.
 - Removing privileges on test database...
Success.

Reload privilege tables now? (Press y|Y for Yes) : Yes
Success.

All done!

4. Подключитесь к базе данных MySQL от имени пользователя root и создайте тестовую базу данных.

$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, 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> SELECT version();
+-----------+
| version() |
+-----------+
| 8.0.13    |
+-----------+
1 row in set (0.00 sec)

Создайте тестовую базу данных и пользователя

mysql> CREATE DATABASE test_db;
Query OK, 1 row affected (0.09 sec)

mysql> CREATE USER 'test_user'@'localhost' IDENTIFIED BY "Strong34S;#";
Query OK, 0 rows affected (0.04 sec)

mysql> GRANT ALL PRIVILEGES ON test_db.* TO 'test_user'@'localhost';
Query OK, 0 rows affected (0.02 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.02 sec)

Эту тестовую базу данных и пользователя можно удалить, запустив:

mysql> DROP DATABASE test_db;
Query OK, 0 rows affected (0.14 sec)

mysql> DROP USER 'test_user'@'localhost';
Query OK, 0 rows affected (0.11 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> QUIT
Bye

Шаг 4. Настройка брандмауэра

Чтобы разрешить удаленные подключения, разрешите порт 3306 на брандмауэре.

sudo firewall-cmd --add-service=mysql --permanent
sudo firewall-cmd --reload

Вы также можете ограничить доступ из доверенных сетей

sudo firewall-cmd --permanent --add-rich-rule 'rule family="ipv4" \
service name="mysql" source address="10.1.1.0/24" accept'

Спасибо за установку MySQL 8.0 на Fedora 31/30/29 с нашим руководством. До следующего раза, следите за обновлениями.

Один комментарий

Комментарии закрыты.