
Contents
実行環境(OS)、動機 インストーラではなく ZIP をダウンロード(昨日) - 実行環境(コンソール)、データベース初期化
- 最初のサーバ起動、ログイン、パスワード設定
- サーバ終了コマンドと、起動・終了バッチファイル
補足:サーバを起動する Windows ユーザの種別について 空間データのインポート ①(明日) 同 ② (明後日)
実行環境(コンソール)、データベース初期化
今日の操作はほぼコンソールのみで、Windows昨日は適当なフォルダに

昨日紹介したStack Overflow - MySql portable versionを参考に、最小限の
[mysqld] basedir="." datadir="data" sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
初期化は公式マニュアル ↓ に解説があり、mysqld --initialize
With --initialize but not --initialize-insecure, the server generates a random password, marks it as expired, and writes a message displaying the password: [Warning] A temporary password is generated for root@localhost: iTag*AfrH5ej
R: cd "/MySQL-5.7.8" "bin/mysqld" --initialize --user=mysql
ところが一時パスワードが表示されないまま ↓ 一応データベース初期化は完了。あれ~と思いながらサーバを起動して接続を試みても、当然パスワードなしではログインできません(二つ目の画像。サーバ起動については次項で)。


いったんデータフォルダを消去し、--initialize-insecure
"bin/mysqld" --initialize-insecure --user=mysql

↓ 初期化によって作られたデータフォルダの中。「コンピュータ名

最初のサーバ起動、ログイン、パスワード設定
初期化できていればサーバ起動は簡単で、bin"bin/mysqld"


サーバに接続するクライアントは
"bin/mysql" -u root

ただ、MySQL 5.7 Reference Manual - Initializing the Data Directory Using mysqldにならって初期化コマンドに
ともかく
mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY '********';

上の画像でも、初期化時に指定した
サーバ終了コマンドと、起動・終了バッチファイル
コンソールで調べた結果、bin
"bin/mysqladmin" shutdown -u root -p


以上で簡単なサーバ起動・終了のコマンドが分かったので、とりあえず別々にバッチファイルを作成。本当は普段
:: start.bat @echo off cd %~dp0 "bin/mysqld" :: stop.bat @echo off cd %~dp0 "bin/mysqladmin" shutdown -u root -p

↑ こんな感じで


ConEmu

明日は、MySQL 5.7