リリースからこの記事を書くまでに少し時間が空いてしまいましたが、
思い起こせば第2回 MySQLにはじめてのデータを入れてみるの時にはデモンストレーション環境としてMySQL 5.
せっかくなので今回も、
時間のない人のための4行まとめ
- 第8回 MySQLのバージョン体系を知るの時点と同じく、
MySQL 5. 7のyumリポジトリーを向いた mysql-release
パッケージがインストールされているものとします yum upgrade
でMySQL 5.7.22にアップグレードします - MySQL Shellをインストールし、
checkForServerUpgradeを実行します - MySQL 8.
0のyumリポジトリーを向いた mysql-release
パッケージに入れ替え、yum upgrade
を実行します
第8回の時点でのおさらい
- MySQL Yum Repositoryを使用して、
MySQL 5. 7.9のパッケージがインストールされています。
$ rpm -qa | grep -i mysql mysql-community-libs-5.7.9-1.el6.x86_64 mysql-community-server-5.7.9-1.el6.x86_64 mysql57-community-release-el6-7.noarch mysql-community-common-5.7.9-1.el6.x86_64 mysql-community-client-5.7.9-1.el6.x86_64
- 古い
(2015年12月時点の) mysql57-community-release
パッケージがインストールされており、ここにはまだMySQL 8. 0用のリポジトリーはリストされていません。
$ cat /etc/yum.repos.d/mysql-community.repo ... [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
MySQL 5.7.22へのアップグレード
まずは同じMySQL 5.yum upgrade
でバージョンアップしましょう。
$ sudo yum upgrade mysql-community-server .. ============================================================================================================================== Package Arch Version Repository Size ============================================================================================================================== Updating: mysql-community-server x86_64 5.7.22-1.el6 mysql57-community 153 M Updating for dependencies: mysql-community-client x86_64 5.7.22-1.el6 mysql57-community 23 M mysql-community-common x86_64 5.7.22-1.el6 mysql57-community 332 k mysql-community-libs x86_64 5.7.22-1.el6 mysql57-community 2.1 M Transaction Summary ============================================================================================================================== Upgrade 4 Package(s) ..
この時点でmysqld
プロセスは再起動されます。
mysql_
$ mysql_upgrade -uroot .. mysql.user OK Upgrading the sys schema. Checking databases. ls.ls OK sys.sys_config OK vmstat.vmstat OK zipcode.prefecture_kana OK zipcode.zipcode OK Upgrade process completed successfully. Checking if update is needed.
MySQL Shellのインストールとアップグレードチェッカーの実行
MySQL Shellはmysql
コマンドと同じくMySQLのコマンドラインクライアントプログラムです。mysql
コマンドに比べさまざまな拡張が加えられた次世代のコマンドラインクライアントであり、
リポジトリーmysql57-community-release
パッケージに含まれているため、yum install
コマンドで簡単に利用を開始できます。
$ sudo yum install mysql-shell .. ============================================================================================================================== Package Arch Version Repository Size ============================================================================================================================== Installing: mysql-shell x86_64 8.0.11-1.el6 mysql-tools-community 4.8 M Transaction Summary ============================================================================================================================== Install 1 Package(s) ..
2018/
$ mysqlsh -uroot -S /var/lib/mysql/mysql.sock Creating a session to 'root@/var%2Flib%2Fmysql%2Fmysql.sock' Enter password: Fetching schema names for autocompletion... Press ^C to stop. Your MySQL connection id is 5 Server version: 5.7.22 MySQL Community Server (GPL) No default schema selected; type \use <schema> to set one. MySQL Shell 8.0.11 Copyright (c) 2016, 2018, 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 '\?' for help; '\quit' to exit. MySQL localhost JS >
MySQL Shellはyum
でインストールしてもデフォルトでは/var/
を向いていないため、-S
オプションで指定する必要があります。
MySQL Shellには "JavaScript", "Python", "SQL" の3モードがあり、mysql
コマンドと同じような操作をするには"SQL"モードに設定する必要があります。アップグレードチェッカーは "JavaScript" モードで使用します。
MySQL localhost JS > util.checkForServerUpgrade() The MySQL server at /var%2Flib%2Fmysql%2Fmysql.sock will now be checked for compatibility issues for upgrade to MySQL 8.0... MySQL version: 5.7.22 - MySQL Community Server (GPL) 1) Usage of db objects with names conflicting with reserved keywords in 8.0 No issues found 2) Usage of utf8mb3 charset No issues found 3) Usage of use ZEROFILL/display length type attributes No issues found 4) Issues reported by 'check table x for upgrade' command No issues found 5) Table names in the mysql schema conflicting with new tables in 8.0 No issues found 6) Usage of old temporal type No issues found 7) Foreign key constraint names longer than 64 characters No issues found 8) Usage of obsolete MAXDB sql_mode flag No issues found 9) Usage of obsolete sql_mode flags No issues found 10) Usage of partitioned tables in shared tablespaces No issues found 11) Usage of removed functions No issues found No known compatibility errors or issues for upgrading the target server to MySQL 8 were found. 0
util.
を実行すると、
MySQL 5.
アップグレードチェッカーで互換性の問題が検出された場合、
MySQL 8.0.11へのアップグレード
アップグレードチェッカーで問題が検出されなければ、
現在MySQL 5.mysql57-community-release
のパッケージをアンインストールし、mysql80-community-release
のパッケージをインストールしますmysql57-community-release
パッケージにもMySQL 8.yum-config-manager
などで設定を変更することでも対応できる場合がありますが、
$ sudo yum remove mysql57-community-release $ sudo yum install https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm $ cat /etc/yum.repos.d/mysql-community.repo .. [mysql80-community] name=MySQL 8.0 Community Server baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql ..
mysql80-community-release
パッケージをインストールしたら、yum upgrade
でMySQL 8.
$ sudo yum upgrade mysql-community-server .. ============================================================================================================================== Package Arch Version Repository Size ============================================================================================================================== Updating: mysql-community-server x86_64 8.0.11-1.el6 mysql80-community 378 M Updating for dependencies: mysql-community-client x86_64 8.0.11-1.el6 mysql80-community 28 M mysql-community-common x86_64 8.0.11-1.el6 mysql80-community 656 k mysql-community-libs x86_64 8.0.11-1.el6 mysql80-community 2.5 M
先ほどと同じく、mysqld
は再起動します。
MySQL 5.mysql_
を実行して再起動することでこのエラーは収まります。
$ mysql_upgrade Checking if update is needed. Checking server version. Running queries to upgrade MySQL server. Upgrading system table data. Checking system database. ... Upgrade process completed successfully. Checking if update is needed. $ sudo service mysqld restart Stopping mysqld: [ OK ] Starting mysqld: [ OK ] $ sudo less /var/log/mysqld.log ... 2018-07-17T10:28:46.408223Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.11) starting as process 1393 2018-07-17T10:28:46.784815Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2018-07-17T10:28:46.809878Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.11' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
まとめ
今回はyumリポジトリーを利用した環境で、
リリースから4か月とまだまだ情報の少ないMySQL 8.