質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Q&A

解決済

3回答

2299閲覧

MySQLのmy.iniでdatadirが変更できない

kaya_miyoshi

総合スコア23

Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

0グッド

1クリップ

投稿2018/11/03 10:28

Windows 10でMySQL8.0.13のmy.iniに

datadir=D:/Temp

の変更を加えMySQLのサービスを再起動して

mysql> show variables like 'datadir';
+---------------+---------------------------------------------+
| Variable_name | Value |
+---------------+---------------------------------------------+
| datadir | C:\ProgramData\MySQL\MySQL Server 8.0\Data\ |
+---------------+---------------------------------------------+
1 row in set, 1 warning (0.01 sec)

...でdatadirが変更されてません。

どうしたらdatadirの変更が出来ますか?

ー my.ini(途中まで) ー

# Other default tuning values # MySQL Server Instance Configuration File # ---------------------------------------------------------------------- # Generated by the MySQL Server Instance Configuration Wizard # # # Installation Instructions # ---------------------------------------------------------------------- # # On Linux you can copy this file to /etc/my.cnf to set global options, # mysql-data-dir/my.cnf to set server-specific options # (@localstatedir@ for this installation) or to # ~/.my.cnf to set user-specific options. # # On Windows you should keep this file in the installation directory # of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To # make sure the server reads the config file use the startup option # "--defaults-file". # # To run the server from the command line, execute this in a # command line shell, e.g. # mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini" # # To install the server as a Windows service manually, execute this in a # command line shell, e.g. # mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini" # # And then execute this in a command line shell to start the server, e.g. # net start MySQLXY # # # Guidelines for editing this file # ---------------------------------------------------------------------- # # In this file, you can use all long options that the program supports. # If you want to know the options a program supports, start the program # with the "--help" option. # # More detailed information about the individual options can also be # found in the manual. # # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-default... # # # CLIENT SECTION # ---------------------------------------------------------------------- # # The following options will be read by MySQL client applications. # Note that only client applications shipped by MySQL are guaranteed # to read this section. If you want your own MySQL client program to # honor these values, you need to specify it as an option during the # MySQL client library initialization. # [client] # pipe= # socket=MYSQL port=3306 default-character-set=utf8 [mysql] no-beep default-character-set=utf8 # SERVER SECTION # ---------------------------------------------------------------------- # # The following options will be read by the MySQL Server. Make sure that # you have installed the server correctly (see above) so it reads this # file. # # server_type=3 [mysqld] character-set-server=utf8 # The next three options are mutually exclusive to SERVER_PORT below. # skip-networking # enable-named-pipe # shared-memory # shared-memory-base-name=MYSQL # The Pipe the MySQL Server will use # socket=MYSQL # The TCP/IP Port the MySQL Server will listen on port=3306 # Path to installation directory. All paths are usually resolved relative to this. # basedir="C:/Program Files/MySQL/MySQL Server 8.0/" # Path to the database root #datadir=C:/ProgramData/MySQL/MySQL Server 8.0/Data datadir=D:/Temp # The default character set that will be used when a new schema or table is # created and no character set is defined # character-set=utf8 # The default authentication plugin to be used when connecting to the server default_authentication_plugin=caching_sha2_password # The default storage engine that will be used when create new tables when default-storage-engine=INNODB

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答3

0

いくつか確認して頂きたい点がありますが、まずは起動するMySQLサービスが参照するmy.iniの配置場所と、my.iniの指定方法について確認してください。

my.iniの場所と指定方法について

まず、指定方法ですがMySQLサービスの起動時に--defaults-fileオプションでmy.iniの場所を明示的に指定されているのでしょうか?
指定されている場合、その場所にmy.iniが存在しているか確認してみてください。

--defaults-fileでmy.iniの場所を指定していないのであれば、my.iniを配置している場所を確認してください。
明示的に指定しない場合、MySQLは決められたルールに則ってmy.iniを自動的に検索して読み込みます。
そのルール(検索場所)については、他の回答者が示されているように--helpで確認できます。

たとえば、コマンドプロンプトを開いて下記のコマンドを実行します。
(この例では、出力内容が多いのでhelp.txtというテキストファイルに保存しています。)

> mysqld.exe --help --verbose > help.txt

出力内容に、下記のような行が出力されていると思います。これがMySQLがmy.ini (またはmy.cnf)を検索する場所と順番です。(左から優先的に検索します)

text

1Default options are read from the following files in the given order: 2C:\WINDOWS\my.ini C:\WINDOWS\my.cnf C:\my.ini C:\my.cnf D:\dev\mysql-8.0.13-winx64\my.ini D:\dev\mysql-8.0.13-winx64\my.cnf

また、出力内容の後半にVariablesの一覧が出力されているはずです。
datadirというキーワードで検索すると、その設定内容が確認できると思います。

my.iniが複数存在しないか検索

それから、念のため複数のmy.ini (またはmy.cnf)が存在していないか確認してみてください。
コマンドプロンプトを開いて下記のコマンドを実行します。
この例のdirコマンドは「Cドライブ内にあるmy.iniファイルとmy.cnfを検索して、見つかればその場所を表示」します。

> cd c:\ > dir /s my.ini > dir /s my.cnf

環境変数の確認

環境変数にMYSQL_HOMEを登録しているか確認してください。
下記のコマンドを実行して何かしらのディレクトリが表示された場合は、設定されているということになります。
そのディレクトリ内にmy.ini (またはmy.cnf)がないか確認してみてください。
コマンドの結果が%MYSQL_HOME%と出力された場合は、設定されていないので無視してかまいません。

> echo %MYSQL_HOME%

MySQLが複数インストールされていないか

MySQLを複数インストールされているということはないでしょうか?
my.iniを探したときと同じように、下記のコマンドで検索してみてください。結果が複数あった場合、複数のMySQLをインストールしている可能性があります。

> dir /s mysqld.exe

以上ご確認をお願いいたします。

投稿2018/11/03 14:15

rubytomato

総合スコア1752

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kaya_miyoshi

2018/11/03 18:49

> mysqld.exe --help --verbose > help.txt Default options are read from the following files in the given order: C:\WINDOWS\my.ini C:\WINDOWS\my.cnf C:\my.ini C:\my.cnf C:\Program Files\MySQL\MySQL Server 8.0\my.ini C:\Program Files\MySQL\MySQL Server 8.0\my.cnf C:\Users\SEEDAGX>cd c:\ c:\>dir /s my.ini ドライブ C のボリューム ラベルは Windows です ボリューム シリアル番号は 00DA-7CAC です c:\ProgramData\MySQL\MySQL Server 8.0 のディレクトリ 2018/11/02 16:29 13,767 my.ini 1 個のファイル 13,767 バイト c:\Users\All Users\MySQL\MySQL Server 8.0 のディレクトリ 2018/11/02 16:29 13,767 my.ini 1 個のファイル 13,767 バイト c:\Users\SEEDAGX\AppData\Local\VirtualStore\ProgramData\MySQL\MySQL Server 8.0 のディレクトリ 2018/11/03 16:54 13,823 my.ini 1 個のファイル 13,823 バイト ファイルの総数: 3 個のファイル 41,357 バイト 0 個のディレクトリ 180,480,151,552 バイトの空き領域 c:\>dir /s my.cnf ドライブ C のボリューム ラベルは Windows です ボリューム シリアル番号は 00DA-7CAC です ファイルが見つかりません c:\>echo %MYSQL_HOME% %MYSQL_HOME% c:\>dir /s mysqld.exe ドライブ C のボリューム ラベルは Windows です ボリューム シリアル番号は 00DA-7CAC です c:\Program Files\MySQL\MySQL Server 8.0\bin のディレクトリ 2018/10/07 11:36 46,325,760 mysqld.exe 1 個のファイル 46,325,760 バイト ファイルの総数: 1 個のファイル 46,325,760 バイト 0 個のディレクトリ 180,508,516,352 バイトの空き領域 ...で、問題ないと思います。my.iniは実行ファイルのパス "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" MySQL80 ...で、C:\ProgramData\MySQL\MySQL Server 8.0\my.iniとして存在してますし、 my.iniの変更が反映されないです。
guest

0

自己解決

my.iniを管理者権限でエディタを開いて編集すると解決しました。お騒がせしました。丁寧に回答していただいてありがとうございました。

投稿2018/11/04 00:17

kaya_miyoshi

総合スコア23

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

つmysqld --help

投稿2018/11/03 11:59

hichon

総合スコア5737

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kaya_miyoshi

2018/11/03 18:52

c:\>mysqld --help mysqld.exe Ver 8.0.13 for Win64 on x86_64 (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. Starts the MySQL database server. Usage: mysqld.exe [OPTIONS] For more help options (several pages), use mysqld --verbose --help. ...で、問題ないと思います。my.iniの変更が反映されてないと思います。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問