概要
Windows 7に開発・検証目的用にMySQL Community Server 5.7.7 rcをインストールし、初歩的な設定を行うまでの作業メモです。
MySQLはZIP Archiveを使用します。
環境
この記事の内容は下記のバージョンで動作確認を行いました。
- Windows 7 (64bit)
- MySQL Community Server 5.7.7 rc
参考サイト
下記のサイトの内容を参考にしました。
- MySQL
- MySQL 5.7 Reference Manual
- MySQL 5.7 Reference Manual - What Is New in MySQL 5.7
- 今から備えるMySQL最新バージョン5.7 - Slideshare
インストール
アーカイブファイルのダウンロード
ダウンロードページよりアーカイブファイルをダウンロードします。
今回ダウンロードしたファイルはmysql-5.7.7-rc-winx64.zip
です。
アーカイブファイルの展開
アーカイブファイルを適当な場所(D:/dev/mysql-5.7.7-rc-winx64
にしました)へ展開します。
また、次のディレクトリを作成します。
D:/dev/mysql-5.7.7-rc-winx64/logs
D:/dev/mysql-5.7.7-rc-winx64/tmp
my.iniの準備
D:/dev/mysql-5.7.7-rc-winx64/my-default.ini
というテンプレートファイルをmy.ini
へリネームし、下記のように修正します。
MySQL 5.7 Reference Manual - Server System Variables
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
+ innodb_buffer_pool_size = 64M
+ innodb_file_per_table = 1
+ innodb-status-output = 0
+ innodb-status-output-locks = 0
+
+ default-storage-engine = innodb
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
+ log_bin = mysql-bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
+ basedir = "D:/dev/mysql-5.7.7-rc-winx64"
+ datadir = "D:/dev/mysql-5.7.7-rc-winx64/data"
+ tmpdir = "D:/dev/mysql-5.7.7-rc-winx64/tmp"
+ port = 3306
+ server_id = 1
+
+ character-set-server = utf8
+ collation-server = utf8_general_ci
+
+ transaction-isolation = REPEATABLE-READ
# Logging
+ log_output = FILE
+ log_error_verbosity = 3
+ log_error = "D:/dev/mysql-5.7.7-rc-winx64/logs/mysqld_error.log
+ general_log = 1
+ general_log_file = "D:/dev/mysql-5.7.7-rc-winx64/logs/general_query_all.log"
+ log-slow-admin-statements = 1
+ log-queries-not-using-indexes = 1
+ slow_query_log = 1
+ long_query_time = 1
+ slow_query_log_file = "D:/dev/mysql-5.7.7-rc-winx64/logs/slow_query.log"
+ log_syslog = 0
+ log_timestamps = SYSTEM
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
- sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
+ sql_mode = ONLY_FULL_GROUP_BY,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
+
+ # autocommit = 0
+ explicit_defaults_for_timestamp = true
+
+ default_password_lifetime = 0
+ secure-file-priv = empty
+
+ [mysql]
+ default-character-set = utf8
+ show-warnings
+
5.7で変更のあったオプション
log_warnings
非推奨:5.7.2
log_warnings
は非推奨になりました。設定されているとワーニングが出力されます。
[Warning] The syntax '--log_warnings/-W' is deprecated and will be removed in a future release. Please use '--log_error_verbosity' instead.
log_error_verbosity
導入:5.7.2
log_warnings
の代わりにログの出力制御を設定します。
- Default Value: 3
- Min Value: 1
- Max Value: 3
Verbosity Value | Message Types Logged |
---|---|
1 | Errors only |
2 | Errors and warnings |
3 | Errors, warnings, and notes |
log_syslog
導入:5.7.5
エラーログをWindowsのイベントログへ出力できます。
- Default Value: 1 (ON)
なお、mysql serverを管理者モードで実行しないとイベントログに書き込めずエラーが発生します。
[ERROR] Cannot open Windows EventLog; check privileges, or start server with --log_syslog=0
secure-file-priv
変更:5.7.6
デフォルトの設定が変わりました。5.7.6からsecure_file=priv
が設定されていないとワーニングが出力されます。
[Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
default_password_lifetime
導入:5.7.4
パスワードの有効日数のデフォルト値の設定
- Default Value: 360
- Min Value: 0 (無効化)
- Max Value: 65535
log_timestamps
導入:5.7.2
ログに出力するtimestampのタイムゾーンの設定
- Default Value: UTC
- Valid Values: UTC, SYSTEM
mysql serverの起動と接続
起動
> D:\dev\mysql-5.7.7-rc-winx64\bin\mysqld.exe --defaults-file=D:\dev\mysql-5.7.7-rc-winx64\my.ini --console
rootユーザーでログイン
> D:\dev\mysql-5.7.7-rc-winx64\bin\mysql.exe -u root -p
停止
> D:\dev\mysql-5.7.7-rc-winx64\bin\mysqladmin.exe -u root -p shutdown
mysqldのオプションの確認と設定値の出力
(結果が長いのでtextファイルに出力しています。)
> D:\dev\mysql-5.7.7-rc-winx64\bin\mysqld.exe --help --verbose > option_dump.txt
インストール後の設定
rootユーザーのパスワード設定
rootユーザーでログイン
> D:\dev\mysql-5.7.7-rc-winx64\bin\mysql.exe -u root -p
rootユーザーのパスワードを変更(パスワードは伏せています)
set passwordの構文が変わりました。
mysql> set password for 'root'@'localhost' = password('******');
Warning (Code 1287): 'SET PASSWORD FOR <user> = PASSWORD('<plaintext_password>')' is deprecated and will be removed in a future release. Please use SET PASSWORD FOR <user> = '<plaintext_password>' ins
tead
新しい構文は下記の通りです。
mysql> set password for 'root'@'localhost' = '*******';
Query OK, 0 rows affected (0.00 sec)
不要なユーザーの削除
デフォルトで作成されるユーザーは'root'@'localhost'
だけになりました。
mysql> select host,user from mysql.user;
+-----------+------+
| host | user |
+-----------+------+
| localhost | root |
+-----------+------+
1 row in set (0.00 sec)
キャラクターセットの確認
利用できるキャラクターセットの一覧
mysql> show character set;
一部抜粋です。
Charset | Description | |
---|---|---|
cp850 |
DOS West European | |
latin1 |
cp1252 West European | |
latin2 |
ISO 8859-2 Central European | |
ascii |
US ASCII | |
ujis |
EUC-JP Japanese | |
sjis |
Shift-JIS Japanese | |
greek |
ISO 8859-7 Greek | |
cp1250 |
Windows Central European | |
latin5 |
ISO 8859-9 Turkish | |
utf8 |
UTF-8 Unicode | |
ucs2 |
UCS-2 Unicode | |
cp852 |
DOS Central European | |
latin7 |
ISO 8859-13 Baltic | |
utf8mb4 |
UTF-8 Unicode | |
utf16 |
UTF-16 Unicode | |
utf16le |
UTF-16LE Unicode | |
cp1256 |
Windows Arabic | |
cp1257 |
Windows Baltic | |
utf32 |
UTF-32 Unicode | |
cp932 |
SJIS for Windows Japanese | |
eucjpms |
UJIS for Windows Japanese |
mysql> show variables like "char%";
+--------------------------+----------------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | D:\dev\mysql-5.7.7-rc-winx64\share\charsets\ |
+--------------------------+----------------------------------------------+
8 rows in set (0.00 sec)