CentOS 8.5にMySQL 8.0をインストールする
環境
OSバージョンの確認
# cat /etc/redhat-release
CentOS Linux release 8.5.2111
インストールの方法
1.MySQL をインストールします
# dnf module -y install mysql:8.0
2.配置ファイルを設定します
# vi /etc/my.cnf.d/mysql-server.cnf
最終行に文字コードを追記します
[mysqld]
character-set-server=utf8mb4
3.mysqlを有効にします
# systemctl enable –now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
4.ファイアウォールを設定します
# firewall-cmd --add-service=mysql --permanent success # firewall-cmd --reload success
5.MySQLの初期設定を行います
# 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: 0 Please set the password for root here. 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 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: 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> select version(); +-----------+ | version() | +-----------+ | 8.0.26 | +-----------+ 1 row in set (0.00 sec)