MySQL8.0をインストールします。
リポジトリをインストール
CentOS 7標準のリポジトリをインストールします。
sudo yum localinstall http://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
MySQLをインストール
MySQLをインストールします。
sudo yum -y install mysql-community-server
my.cnf設定
MySQL設定を変更します。
・ログのタイムゾーンの設定
・クライアントの文字セットの設定を無視する
・デフォルトの文字セット
・タイムスタンプのデフォルト値設定
sudo vi /etc/my.cnf
変更後
(赤字が追加箇所)
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
log_timestamps=SYSTEM
skip-character-set-client-handshake
character-set-server=utf8mb4
explicit_defaults_for_timestamp=ON
MySQLの自動起動設定
VPSを再起動した場合、MySQLを自動で起動させるようにします。
sudo systemctl enable mysqld
MySQLの起動
MySQLを起動します。
sudo systemctl restart mysqld
初期パスワードの確認
MySQLにログインするために初期パスワードを確認します。
sudo vi /var/log/mysqld.log
temporary passwordを探し、初期パスワードを確認。
(赤字が初期パスワード)
[Server] A temporary password is generated for root@localhost: xxxxxxxxxxxx
MySQLにログイン
MySQLにログインします。
mysql -uroot -p
初期パスワードを入力し、ログインできることを確認する。
# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 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 '\h' for help. Type '\c' to clear the current input statement.
mysql>
MySQLのrootログインパスワードの変更
rootログインのパスワードを変更します。
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '(新パスワード)';