LoginSignup
1
2

More than 3 years have passed since last update.

MySQL 8.0.19 Install on CentOS

Last updated at Posted at 2020-04-26

はじめに

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

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

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>

MySQL Shell Install

インストール

sudo yum install mysql-shell -y

依存関係

========================================================================================================================
 Package                   Arch                 Version                       Repository                           Size
========================================================================================================================
Installing:
 mysql-shell               x86_64               8.0.23-1.el7                  mysql-tools-community                32 M

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

MySQL Shell 上で Object Storage を扱うために、OCI CLI をインストールしておくと便利
https://qiita.com/sugimount/items/63a8cfe1163030ae8804

外部接続用ユーザー作成

root ユーザーは、localhost のみ

mysql> select user,host from mysql.user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
7 rows in set (0.00 sec)

mysql>

今回は、フル権限の自分のアカウントを作成

CREATE USER sugi01@'%' IDENTIFIED BY 'mIfoO8_fai12#-gai897fao';
grant all on *.* to sugi01@'%';

参考URL

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2