AlmaLinux 8.4にMySQL8をインストールする
1.バージョンを確認
# dnf info mysql
利用可能なパッケージ 名前 : mysql バージョン : 8.0.26 リリース : 1.module_el8.4.0+2532+b8928c02 Arch : x86_64 サイズ : 12 M ソース : mysql-8.0.26-1.module_el8.4.0+2532+b8928c02.src.rpm リポジトリー : appstream 概要 : MySQL client programs and shared libraries URL : http://www.mysql.com ライセンス : GPLv2 with exceptions and LGPLv2 and BSD 説明 : MySQL is a multi-user, multi-threaded SQL database server. MySQL : is a client/server implementation consisting of a server daemon : (mysqld) and many different client programs and libraries. The : base package contains the standard MySQL client programs and : generic MySQL files.
2.mysql8をインストール
# sudo dnf install @mysql:8.0
略 インストール済み: mariadb-connector-c-config-3.1.11-2.el8_3.noarch mecab-0.996-1.module_el8.4.0+2532+b8928c02.9.x86_64 mysql-8.0.26-1.module_el8.4.0+2532+b8928c02.x86_64 mysql-common-8.0.26-1.module_el8.4.0+2532+b8928c02.x86_64 mysql-errmsg-8.0.26-1.module_el8.4.0+2532+b8928c02.x86_64 mysql-server-8.0.26-1.module_el8.4.0+2532+b8928c02.x86_64 protobuf-lite-3.5.0-13.el8.x86_64
3.バージョンの確認
# mysql –version
mysql Ver 8.0.26 for Linux on x86_64 (Source distribution)
4.自動起動
# sudo systemctl enable –now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
5.初期設定
# 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 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 Please set the password for root here. #パスワードの設定 New password:Test12345@ Re-enter new password:Test12345@ #設定パスワードで問題ないか 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. # rootでのリモート接続を禁止 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に接続
# mysql -uroot -p Enter password:Test12345@ Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.26 Source distribution Copyright (c) 2000, 2021, 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>