ダウンロード
インストール
- zipファイルを解凍 ex) C:\mysql
初期設定
- 環境変数にPathを追加 ex) C:\mysql\bin
- dataフォルダの作成 ex) C:\mysql\data
- my-default.iniをコピー ex) C:\mysql\my.ini
my.ini
[client]
default-character-set = utf8
[mysqld]
character-set-server = utf8
basedir = c:\mysql
datadir = c:\mysql\data
データベース初期化
mysqld --initialize-insecure --console
> mysqld --initialize-insecure --console
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
[Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
[Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
[Warning] InnoDB: New log files created, LSN=45790
[Warning] InnoDB: Creating foreign key constraint system tables.
[Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 70cd7ed1-e226-22d6-0247-65z162zzc1e2.
[Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
[Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
データベース起動
mysqld --console
ログイン
mysql -u root
パスワード設定
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('YourPassword');
mysql> SET PASSWORD FOR 'root'@'localhost'=PASSWORD('YourPassword');
Query OK, 0 rows affected, 1 warning (0.00 sec)
パスワードの確認
SELECT user,host,authentication_string FROM mysql.user;
mysql> SELECT user,host,authentication_string FROM mysql.user;
+-----------+-----------+-------------------------------------------+
| user | host | authentication_string |
+-----------+-----------+-------------------------------------------+
| root | localhost | *XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+-----------+-----------+-------------------------------------------+
2 rows in set (0.00 sec)
文字コードの確認
show variables like '%char%';
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 | c:\mysql\share\charsets\ |
+--------------------------+----------------------------+
8 rows in set, 1 warning (0.00 sec)
インストール時に嵌ったポイント
- 以下のErrorが発生してmysqld起動しない
[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
解決: mysqld --initialize-insecure --consoleの実行
- mysqld --initialize --consoleだと、以下のErrorでPASSWORDのリセットが出来ない
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
解決: mysqld --initialize-insecure --consoleの実行
※ マニュアルをよく読むとかいてありました…^^;
解決: 以下のコマンドでPASSWORDの再設定が出来ました
> mysqld --initialize --console
:
[Note] A temporary password is generated for root@localhost: XXXXXXXXXXXX
> mysql -u root -p
Enter password: XXXXXXXXXXXX
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new Password';
Query OK, 0 rows affected (0.00 sec)