LoginSignup
4
2

More than 3 years have passed since last update.

CentOS7.6にMySQL8.0をyumでインストールする

Posted at

テスト用に新しい環境を作ってみたのでメモ :writing_hand_tone2:
環境はおなじみConoha VPSです :clap_tone2:

▼OS

cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 

CentOS7.6にMySQL8.0をyumでインストールする

1.MySQL8.0のインストール

(参考)https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

1-1.公式リポジトリを追加

最新は 「mysql80-community-release-el7-3.noarch.rpm」 のよう。
DL用のURLはサイトたどったら以下の通りでした :information_desk_person:
サクッといきます:ok_hand_tone2:

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

1-2.mysqlをインストール

$ sudo yum install --enablerepo=mysql80-community mysql-community-server

1-3.確認する

$ mysqld --version
/usr/sbin/mysqld  Ver 8.0.16 for Linux on x86_64 (MySQL Community Server - GPL)

よーし :ok_woman:
あ、mariaDBもちゃんと置換されてるみたいだった:v_tone2:

▼ログ

置換:
  mariadb-libs.x86_64 1:5.5.60-1.el7_5   

はい、楽勝でしたね :stuck_out_tongue_winking_eye:

あとはおまけです。
MySQL5.7の時とかと全く一緒 :dancer_tone3:

2.おまけ

2-1.自動起動の設定

$ systemctl enable mysqld.service

2-2.起動する

$ systemctl start mysqld.service

2-3.mysqlに入る

パスワードがログに出力されているらしいので、以下のコマンドで確認する。

$ sudo grep 'temporary password' /var/log/mysqld.log
2019-06-19T12:46:39.848469Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: XXXXXXXXXXXX

XXXXXXXXXXXXの部分にパスワードが表示される。
このパスワードを使って入る。

$ mysql -uroot -p
Enter password: XXXXXXXXXXXX
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.16

省略...

入れた :runner_tone1:

2-4.SELECTしてみる

$ mysql> select host, user from mysql.user;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

あちゃ :sweat_smile:
まずは新しいパスワードを設定する必要があるみたい。
パスワードの強度が低いと変更できないので、とりあえずマニュアル通りのパスを設定。

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

でけた :ok_hand_tone2:

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

よーし。
とりあえず使えたワッショイ :lifter:

4
2
1

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
4
2