LoginSignup
0
1

More than 3 years have passed since last update.

CentOS 7にMySQL 8.0をインストール(公式レポジトリ)

Posted at

はじめに

公式レポジトリを使ってCentOS7にMySQL8.0をインストール
親記事:MySQL, MariaDBの各種インストール方法とEOLまとめ - Qiita
参考:MySQL :: MySQL 8.0 Reference Manual :: 2.5.1 Installing MySQL on Linux Using the MySQL Yum Repository

LOG

レポジトリ登録

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

# yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community    disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community -  disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community    disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community -  disabled
mysql-cluster-8.0-community/x86_64 MySQL Cluster 8.0 Community    disabled
mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community -  disabled
mysql-connectors-community/x86_64  MySQL Connectors Community     enabled:   131
mysql-connectors-community-source  MySQL Connectors Community - S disabled
mysql-tools-community/x86_64       MySQL Tools Community          enabled:   100
mysql-tools-community-source       MySQL Tools Community - Source disabled
mysql-tools-preview/x86_64         MySQL Tools Preview            disabled
mysql-tools-preview-source         MySQL Tools Preview - Source   disabled
mysql55-community/x86_64           MySQL 5.5 Community Server     disabled
mysql55-community-source           MySQL 5.5 Community Server - S disabled
mysql56-community/x86_64           MySQL 5.6 Community Server     disabled
mysql56-community-source           MySQL 5.6 Community Server - S disabled
mysql57-community/x86_64           MySQL 5.7 Community Server     disabled
mysql57-community-source           MySQL 5.7 Community Server - S disabled
mysql80-community/x86_64           MySQL 8.0 Community Server     enabled:   145
mysql80-community-source           MySQL 8.0 Community Server - S disabled

mysql80以降が標準になったら下記コマンドで有効レポジトリを切り替える

# yum-config-manager --disable mysql80-community
# yum-config-manager --enable mysql80-community

インストール

# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)

# yum install -y mysql-server
... 略

mysql起動/停止

# systemctl start mysqld
# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2019-11-16 11:17:45 UTC; 42s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 233 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 306 (mysqld)
   Status: "Server is operational"
   CGroup: /docker/ce1745a0a6d6c10bda0aeca5efff3419794de36c221f582b8b5577398624e3d0/system.slice/mysqld.service
           mq306 /usr/sbin/mysqld
           ? 306 /usr/sbin/mysqld

Nov 16 11:17:30 ce1745a0a6d6 systemd[1]: Starting MySQL Server...
Nov 16 11:17:30 ce1745a0a6d6 mysqld_pre_systemd[233]: mysqld: Out of memory (Needed 4294967200 bytes)
Nov 16 11:17:45 ce1745a0a6d6 systemd[1]: Started MySQL Server..
# systemctl stop mysqld
# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Sat 2019-11-16 11:19:39 UTC; 3s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 306 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 233 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 306 (code=exited, status=0/SUCCESS)
   Status: "Server shutdown complete"

Nov 16 11:17:30 ce1745a0a6d6 systemd[1]: Starting MySQL Server...
Nov 16 11:17:30 ce1745a0a6d6 mysqld_pre_systemd[233]: mysqld: Out of memory (Needed 4294967200 bytes)
Nov 16 11:17:45 ce1745a0a6d6 systemd[1]: Started MySQL Server.
Nov 16 11:19:38 ce1745a0a6d6 systemd[1]: Stopping MySQL Server...
Nov 16 11:19:39 ce1745a0a6d6 systemd[1]: Stopped MySQL Server.

mysql自動起動設定/設定解除

# systemctl enable mysqld
# systemctl list-unit-files --type=service |grep mysql
mysqld.service                         enabled
mysqld@.service                        disabled
# systemctl disable mysqld
Removed symlink /etc/systemd/system/multi-user.target.wants/mysqld.service.
# systemctl list-unit-files --type=service |grep mysql
mysqld.service                         disabled
mysqld@.service                        disabled

各種確認

# systemctl start mysqld
# grep 'temporary password' /var/log/mysqld.log
2019-11-16T11:17:37.897986Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: r:oOX6J8H:f,
# mysql -uroot -p

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
Query OK, 0 rows affected (0.01 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.18    |
+-----------+
0
1
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
0
1