MySQL8.0をインストール

開発環境構築

まずは mysqlの互換サーバのMariaDBを削除します。
下記のコマンドを実行

yum remove mariadb-libs
[root@localhost ~]# yum remove mariadb-libs
Loaded plugins: fastestmirror
Resolving Dependencies
–> Running transaction check
—> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be erased
–> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
–> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
–> Running transaction check
—> Package postfix.x86_64 2:2.10.1-9.el7 will be erased
–> Finished Dependency ResolutionDependencies Resolved======================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================
Removing:
mariadb-libs x86_64 1:5.5.68-1.el7 @anaconda 4.4 M
Removing for dependencies:
postfix x86_64 2:2.10.1-9.el7 @anaconda 12 MTransaction Summary
======================================================================================================================================================
Remove 1 Package (+1 Dependent package)

Installed size: 17 M
Is this ok [y/N]: y
yを選択します
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : 2:postfix-2.10.1-9.el7.x86_64 1/2
Erasing : 1:mariadb-libs-5.5.68-1.el7.x86_64 2/2
Verifying : 1:mariadb-libs-5.5.68-1.el7.x86_64 1/2
Verifying : 2:postfix-2.10.1-9.el7.x86_64 2/2

Removed:
mariadb-libs.x86_64 1:5.5.68-1.el7

Dependency Removed:
postfix.x86_64 2:2.10.1-9.el7

次にmysql8をインストールします。

下記のコマンドで直接yumリポジトリーに追加とインストールを行います

yum install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
[root@localhost ~]# yum install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
Loaded plugins: fastestmirror
mysql80-community-release-el7-3.noarch.rpm | 25 kB 00:00:00
Examining /var/tmp/yum-root-5Z6_7P/mysql80-community-release-el7-3.noarch.rpm: mysql80-community-release-el7-3.noarch
Marking /var/tmp/yum-root-5Z6_7P/mysql80-community-release-el7-3.noarch.rpm to be installed
Resolving Dependencies
–> Running transaction check
—> Package mysql80-community-release.noarch 0:el7-3 will be installed
–> Finished Dependency ResolutionDependencies Resolved======================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================
Installing:
mysql80-community-release noarch el7-3 /mysql80-community-release-el7-3.noarch 31 kTransaction Summary
======================================================================================================================================================
Install 1 Package

Total size: 31 k
Installed size: 31 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql80-community-release-el7-3.noarch 1/1
Verifying : mysql80-community-release-el7-3.noarch 1/1

Installed:
mysql80-community-release.noarch 0:el7-3

Complete!

MySQLをインストール
下記のコマンドを実行します
その前に新しいGPGキーをインストールする必要があるので先に鍵をインストールしてから
mysql本体をインストールします

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum --enablerepo=mysql80-community install mysql-community-server
鍵をインストール
rpm –import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
次にmysqlをインストールします
[root@localhost ~]# yum –enablerepo=mysql80-community install mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.riken.jp
* epel: mirrors.bestthaihost.com
* extras: ftp.riken.jp
* remi-safe: ftp.riken.jp
* updates: ftp.riken.jp
Resolving Dependencies
–> Running transaction check
—> Package mysql-community-server.x86_64 0:8.0.31-1.el7 will be installed
–> Processing Dependency: mysql-community-common(x86-64) = 8.0.31-1.el7 for package: mysql-community-server-8.0.31-1.el7.x86_64
–> Processing Dependency: mysql-community-icu-data-files = 8.0.31-1.el7 for package: mysql-community-server-8.0.31-1.el7.x86_64
–> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.31-1.el7.x86_64
–> Running transaction check
—> Package mysql-community-client.x86_64 0:8.0.31-1.el7 will be installed
–> Processing Dependency: mysql-community-client-plugins = 8.0.31-1.el7 for package: mysql-community-client-8.0.31-1.el7.x86_64
–> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.31-1.el7.x86_64
—> Package mysql-community-common.x86_64 0:8.0.31-1.el7 will be installed
—> Package mysql-community-icu-data-files.x86_64 0:8.0.31-1.el7 will be installed
–> Running transaction check
—> Package mysql-community-client-plugins.x86_64 0:8.0.31-1.el7 will be installed
—> Package mysql-community-libs.x86_64 0:8.0.31-1.el7 will be installed
–> Finished Dependency ResolutionDependencies Resolved======================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================
Installing:
mysql-community-server x86_64 8.0.31-1.el7 mysql80-community 64 M
Installing for dependencies:
mysql-community-client x86_64 8.0.31-1.el7 mysql80-community 16 M
mysql-community-client-plugins x86_64 8.0.31-1.el7 mysql80-community 2.5 M
mysql-community-common x86_64 8.0.31-1.el7 mysql80-community 647 k
mysql-community-icu-data-files x86_64 8.0.31-1.el7 mysql80-community 2.1 M
mysql-community-libs x86_64 8.0.31-1.el7 mysql80-community 1.5 MTransaction Summary
======================================================================================================================================================
Install 1 Package (+5 Dependent packages)

Total size: 87 M
Installed size: 409 M
Is this ok [y/d/N]: y
yを選択します。

Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql-community-client-plugins-8.0.31-1.el7.x86_64 1/6
Installing : mysql-community-common-8.0.31-1.el7.x86_64 2/6
Installing : mysql-community-libs-8.0.31-1.el7.x86_64 3/6
Installing : mysql-community-client-8.0.31-1.el7.x86_64 [####################################### ] 4/6
Installing : mysql-community-client-8.0.31-1.el7.x86_64 4/6
Installing : mysql-community-icu-data-files-8.0.31-1.el7.x86_64 5/6
Installing : mysql-community-server-8.0.31-1.el7.x86_64 6/6
Verifying : mysql-community-server-8.0.31-1.el7.x86_64 1/6
Verifying : mysql-community-common-8.0.31-1.el7.x86_64 2/6
Verifying : mysql-community-client-plugins-8.0.31-1.el7.x86_64 3/6
Verifying : mysql-community-icu-data-files-8.0.31-1.el7.x86_64 4/6
Verifying : mysql-community-client-8.0.31-1.el7.x86_64 5/6
Verifying : mysql-community-libs-8.0.31-1.el7.x86_64 6/6

Installed:
mysql-community-server.x86_64 0:8.0.31-1.el7

Dependency Installed:
mysql-community-client.x86_64 0:8.0.31-1.el7 mysql-community-client-plugins.x86_64 0:8.0.31-1.el7
mysql-community-common.x86_64 0:8.0.31-1.el7 mysql-community-icu-data-files.x86_64 0:8.0.31-1.el7
mysql-community-libs.x86_64 0:8.0.31-1.el7

Complete!

これでmysqlをインストール完了しました。

次にmysqlの自動起動の設定を行います。

systemctl enable mysqld.service

次にmysqlを起動します

systemctl start mysqld.service

mysqlの初期パスワードの確認

パスワードを確認するために次のコマンドを実行します

grep password /var/log/mysqld.log
[root@localhost ~]# grep password /var/log/mysqld.log
2022-11-23T12:58:21.077233Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: パスワード

mysqlの初期設定を行います

mysql_secure_installation

[root@localhost ~]# mysql_secure_installationSecuring the MySQL server deployment.

Enter password for user root: 初期パスワードを入力します

The existing password for the user account root has expired. Please set a new password.

New password:新しいパスワードを入力します

Re-enter new password:新しいパスワードを入力します
The ‘validate_password’ component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n 新しいパスワードはとりあえずキャンセルします

… skipping.
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 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) : n nを選択リモートログイン不可

… skipping.
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 yを選択test databaseは不要です
– 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 yを選択して特権テーブルを更新します
Success.

All done!

mysqlにログインする為に下記のコマンドを実行します。

[root@localhost ~]# mysql -u root -p
Enter password: パスワードを入力します
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.31 MySQL Community Server – GPL

Copyright (c) 2000, 2022, 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> <—– mysqlにログインしています

mysqlからのログアウトexit で終了できます

コメント

タイトルとURLをコピーしました