Help us understand the problem. What is going on with this article?

MySQL 8.0.19 Install on CentOS

はじめに

CentOS 7 に、MySQL 8.0.19 をインストール手順を確認します。車輪の再発明ですが、自分の作業の備忘録用メモな意図が強いです。

バージョン情報

  • CentOS 7
  • MySQL 8.0.19

Firewalld 停止

CentOS 上の Firewalld を停止 (他の仕組みでFirewall機能を実施するため)

sudo systemctl stop firewalld
sudo systemctl disable firewalld

MySQL Install

Repository

https://dev.mysql.com/downloads/repo/yum/

sudo yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

repolist

[opc@mysql ~]$ yum repolist
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: nrt.edge.kernel.org
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
repo id                                                             repo name                                                                        statusbase/7/x86_64                                                       CentOS-7 - Base                                                                  10097
epel/x86_64                                                         Extra Packages for Enterprise Linux 7 - x86_64                                   13242 
extras/7/x86_64                                                     CentOS-7 - Extras                                                                  341 
mysql-connectors-community/x86_64                                   MySQL Connectors Community                                                         141 
mysql-tools-community/x86_64                                        MySQL Tools Community                                                              105 
mysql80-community/x86_64                                            MySQL 8.0 Community Server                                                         161 
updates/7/x86_64                                                    CentOS-7 - Updates                                                                1787 
repolist: 25874
[opc@mysql ~]$ 

Install

sudo yum -y install mysql-community-server

依存関係

==============================================================================================================================================================
Package                                          Arch                        Version                            Repository                              Size 
==============================================================================================================================================================
Installing:
 mysql-community-libs                             x86_64                      8.0.19-1.el7                       mysql80-community                      4.0 M 
     replacing  mariadb-libs.x86_64 1:5.5.64-1.el7
 mysql-community-libs-compat                      x86_64                      8.0.19-1.el7                       mysql80-community                      1.3 M 
     replacing  mariadb-libs.x86_64 1:5.5.64-1.el7
 mysql-community-server                           x86_64                      8.0.19-1.el7                       mysql80-community                      436 M 
Installing for dependencies:
 mysql-community-client                           x86_64                      8.0.19-1.el7                       mysql80-community                       41 M 
 mysql-community-common                           x86_64                      8.0.19-1.el7                       mysql80-community                      605 k 

Transaction Summary
==============================================================================================================================================================

起動

sudo systemctl enable mysqld
sudo systemctl start mysqld
sudo systemctl status mysqld

Password の更新

MySQL root ユーザーでログインするために、初期パスワードを確認します

sudo cat /var/log/mysqld.log | grep root

実行例

[opc@mysql ~]$ sudo cat /var/log/mysqld.log | grep root
2020-04-26T11:08:02.818912Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: #nan_jf3Tr>4
[opc@mysql ~]$ 

mysql_secure_installation

mysql_secure_installation

実行例

  • new password : #nan_jf3Tr>41
$ mysql_secure_installation

Securing 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: # root ユーザの新規パスワードを入力します

Re-enter new password: # 確認用にもう一度入力します
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
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) : 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 # ローカルホスト以外からアクセス可能な root アカウントを削除
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 # test データベースの削除
 - 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!

ログイン確認

mysql -u root -p

実行例

[opc@mysql ~]$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.19 MySQL Community Server - GPL

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>

外部からの接続を許可する

vim /etc/my.cnf
bind-address = 127.0.0.1

パスワードの有効期限や文字コード設定などは、今回の手順では省略します。実際に本番に使うときには、色々なパラメータの検討が必要なのでご注意ください。

参考URL

https://enomotodev.hatenablog.com/entry/2016/09/01/225200

sugimount
CloudNativeな色々をやっています / 投稿している内容は個人的な見解なので、所属組織とは関係ありません https://twitter.com/sugimount
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした