「CentOS Stream 8」MySQL8をインストールする方法

OSバージョンを確認
# cat /etc/redhat-release
CentOS Stream release 8
1.バージョンを確認
# dnf info mysql

利用可能なパッケージ
名前         : mysql
バージョン   : 8.0.21
リリース     : 1.module_el8.4.0+589+11e12751
Arch         : x86_64

2.mysql8をインストール
# sudo dnf install @mysql:8.0

略
ダウンロードサイズの合計: 35 M
インストール後のサイズ: 182 M
これでよろしいですか? [y/N]:y
略
インストール済み:
  mariadb-connector-c-config-3.1.11-2.el8_3.noarch
  mecab-0.996-1.module_el8.4.0+589+11e12751.9.x86_64
  mysql-8.0.21-1.module_el8.4.0+589+11e12751.x86_64
  mysql-common-8.0.21-1.module_el8.4.0+589+11e12751.x86_64
  mysql-errmsg-8.0.21-1.module_el8.4.0+589+11e12751.x86_64
  mysql-server-8.0.21-1.module_el8.4.0+589+11e12751.x86_64
  protobuf-lite-3.5.0-13.el8.x86_64

完了しました!

3.バージョンを確認
# mysql –version
mysql Ver 8.0.21 for Linux on x86_64 (Source distribution)

4.自動起動をする
# systemctl enable mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.

mysql起動
# systemctl start mysqld

ステータスを確認
# systemctl status mysqld

5.初期設定
# mysql_secure_installation

略
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:(数値、小文字、大文字、および特殊文字)

Re-enter new password:(数値、小文字、大文字、および特殊文字)

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.

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 -u root -p
Enter password:パスワード

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 8.0.21 Source distribution

Copyright (c) 2000, 2020, 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>

 

CentOS

Posted by arkgame