MySQL — свободная реляционная система управления базами данных, которая, как правило, устанавливается в составе стека LEMP или LAMP.
Установка MySQL в CentOS 8 Stream
MySQL 8 доступен в репозиториях CentOS 8 по умолчанию.
Для установки необходимо выполнить следующую команду
1 | dnf install -y mysql-server |
Включаем автоматический запуск при загрузке сервера
1 | systemctl enable mysqld |
и запускаем службу
1 | systemctl start mysqld.service |
Настройка безопасности MySQL
После окончания установки необходимо выполнить команду ниже, для первоначальной настройки сервера.
1 | mysql_secure_installation |
В результате, скрипт позволит настроить:
- Политики паролей 123456789101112VALIDATE PASSWORD COMPONENT can be used to test passwordsand improve security. It checks the strength of passwordand allows the users to set only those passwords which aresecure enough. Would you like to setup VALIDATE PASSWORD component?Press y|Y for Yes, any other key for No: YThere are three levels of password validation policy:LOW Length >= 8MEDIUM Length >= 8, numeric, mixed case, and special charactersSTRONG Length >= 8, numeric, mixed case, special characters and dictionary filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
- Указать пароль для пользователя root 123Please set the password for root here.New password:Re-enter new password:
- По умолчанию MySQL имеется встроеная учетная запись анонимного пользователя, позволяющая подключаться без пароля. Данный диалог позволяет удалить анонимного пользователя. 123456By default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them. This is intended only fortesting, and to make the installation go a bit smoother.You should remove them before moving into a productionenvironment.Remove anonymous users? (Press y|Y for Yes, any other key for No) :
- Настроить доступ удаленный доступ под пользователем root или запретить его 12345Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess atthe root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) :
- Удалить тестовые данные, которые поставляются по умолчанию 123456By default, MySQL comes with a database named 'test' thatanyone can access. This is also intended only for testing,and should be removed before moving into a productionenvironment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) :
- И применить настройки безопасности, перечитав привилегии пользователей 1234Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) :
На этом настройка MySQL закончена - All done!