再作成中です - Mitsuhiro Yoshida (トーク)

MySQLはMoodleのインストレーションを支えるサポートされたデータベースの1つです。

MySQLをインストールする

  • あなたがLinuxを使用している場合、ディストリビューションのパッケージマネージャを使用したインストールをお勧めします。これにより利用可能なアップデートを確実に入手できます。 しかし、お使いのディストリビューションによってはapt-getまたはyumも使用できます。
  • ほとんどの一般的なオペレーティングシステムに対応したインストーラが用意されています: https://dev.mysql.com/downloads/mysql/
  • ソースからのmysqlビルドは可能であり、それなりに簡単ですが、お勧めしません (ビルド済みのバイナリの方が最適化されていると思われるため)。
  • 「root」ユーザにパスワードを設定していることをご確認ください (詳細は次をご覧ください: https://dev.mysql.com/doc/refman/8.0/en/default-privileges.html)。
  • my.cnf (MySQL設定ファイル) をインストールして、あなたの必要に応じて設定することをご検討ください。デフォルトの設定はメモリ使用量とパフォーマンスの関係で通常非常に保守的なものです。「max_allowed_packet」設定を少なくとも4MBに増やしてください。
  • あなたがプライマリ/レプリカ (マスタ/スレーブ) レプリケーションを使用する場合、[mysqld]内のmy.cnfにbinlog_format = 'ROW'を追加してください。そうでない場合、Moodleはデータベースに書き込めません。

完全なUTF-8サポートを設定する

MySQLで完全なUTF-8サポートの設定をお勧めします。これを設定しない場合、一部の文字セット (特に絵文字) を使用できません。あなたのサイトをインストールした後でも設定可能ですが、インストール前の方がはるかに簡単で早くできます。

これがすでに設定されているかどうかはmysql>プロンプトまたはphpMyAdmin等で以下のステートメントを実行して確認してください:

SHOW GLOBAL VARIABLES WHERE variable_name IN ('innodb_file_format', 'innodb_large_prefix', 'innodb_file_per_table');

ファイル:phpMyAdmin1.png or ファイル:phpMyAdmin2.png or ファイル:phpMyAdmin3.png

表示された設定が上のリストと一致する場合、変更の必要はないため、Moodleデータベースを作成するに進んでください。

あなたの設定がどのリストにも一致しない場合、MySQL設定ファイルを編集する必要があります。If your settings do not match any list you will have to edit the MySQL configuration file. Linuxでは/etc/my.cnf, /etc/mysql/my.cnfまたは/etc/my.cnf.d/mariadb-server.cnfのようになります。Microsoft Windowsでは恐らくmy.iniになると思われます。On Linux this may be /etc/my.cnf, /etc/mysql/my.cnf, or /etc/my.cnf.d/mariadb-server.cnf; on Microsoft Windows it may be my.ini.

  • 注意: 設定ファイルを変更する前にバックアップを取ってください。
  • 注意: この変更の前にすべてのデータベースをバックアップしてください。
  • 注意: このサーバでデータベースを利用する他のシステムはこの変更により影響を受ける可能性があります。

次の設定を設定ファイルに追加してください。もし、あなたが上のSHOW GLOBAL VARIABLES実行時にinnodb_file_format = Barracudaおよびinnodb_large_prefix = 1が空白または見つからない場合は追加しないでください:

[client]
default-character-set = utf8mb4

[mysqld]
innodb_file_format = Barracuda   # 不要であればこの行を削除してください。
innodb_file_per_table = 1
innodb_large_prefix = 1          # 不要であればこの行を削除してください。

character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
skip-character-set-client-handshake

[mysql]
default-character-set = utf8mb4

MySQLサーバプロセスを再起動して、これらの設定を適用してください (LinuxのMariaDBの場合: systemctl restart mariadb)。

これらの設定の適用に問題がある場合、MySQLの完全なUnicodeサポートをご覧ください。

あなたが何らかの理由でここに記述された設定に変更できない場合、Moodleのインストール続行はできますが、デフォルトの文字セットおよび照合順序として、それぞれ、utf8およびutf8_unicode_ciを選択する必要があります。

Moodleデータベースを作成する Creating Moodle database

These are the steps to create an empty Moodle database. Substitute your own database name, user name and password as appropriate. 以下、空のMoodleデータベースの作成手順です。適切なあなたのデータベース名、ユーザ名およびパスワードを入力してください。

このインストラクションはWebサーバおよびMySQLサーバが同じマシン上に存在していることを前提としています。The instructions assume that the web server and MySQL server are on the same machine. この場合、「dbhost」は「localhost」です。In this case the 'dbhost' is 'localhost'. これらのサーバが異なるマシン上にある場合、以下の手順でウェブサーバの名称を「localhost」に置き換えてください。If they are on different machines substitute the name of the web server for 'localhost' in the following instructions and the 'dbhost' setting will be the name of the database server. データベースには「文字セット」および「照合順序」があります。Moodleの場合、私たちは文字セットをutf8mb4、照合順序をutf8mb4_unicode_ciに設定することを推奨します。データベースを作成する際、これらの値を設定するオプションが表示される場合があります。Databases have a "Character set" and a "Collation". For Moodle, we recommend the Character Set be set to utf8mb4 and the Collation utf8mb4_unicode_ci. You may get the option to set these values when you create the database. 選択肢がない場合、恐らくデフォルトのオプションが良いでしょう。古いサーバにインストールした場合、設定が間違っている可能性があります。If you are not given a choice, the default options are probably good. An install on an old server may have the wrong settings.

コマンドライン Command line

  • To create a database using the 'mysql' command line client, first log into MySQL
  • mysqlコマンドラインクライアントでデータベースを作成するには最初にMySQLにログインしてください。
$ mysql -u root -p
Enter password: 

(Enter the password you previously set - or been given - for the MySQL 'root' user). (MySQLの'root'ユーザー用に以前に設定 (または与えられた) パスワードを入力してください)。After some pre-amble this should take you to the mysql> prompt.

  • Create a new database (called 'moodle' - substitute your own name if required).
  • 新しいデータベースを作成してください (データベース名「moodle」 - 必要であれば別のデータベース名を使用してください)。

If you have successfully configured the recommended full UTF-8 support as described above run: あなたが前述の推奨される完全なUTF-8サポートの設定に成功した場合、以下を実行してください:

mysql> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

If you do not have the recommended full UTF-8 support run: 推奨される完全なUTF-8サポートがない場合、以下を実行してください:

mysql> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
  • Add a user/password with the minimum needed permissions:
  • 最低限必要な権限を持つユーザ/パスワードを追加してください:
mysql> CREATE USER moodleuser@localhost IDENTIFIED BY 'yourpassword';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodleuser@localhost;

...which creates a user called 'moodleuser' with a password 'yourpassword'. Make sure you invent a strong password and resist the temptation to 'GRANT ALL'. ... これはパスワード「yourpassword」の「moodleuser」というユーザを作成します。強力なパスワードを作成して、「GRANT ALL」の誘惑に負けないようにしてください。

  • Exit from mysql:
mysql> quit

phpMyAdmin

phpMyAdminはウェブベースのMySQL管理ツールです。phpMyAdmin is a web based administration tool for MySQL. If this is available you can use it to create a new database. あなたが上のように推奨される完全なUTF-8サポートを正常に設定している場合、照合順序utf8mb4_unicode_ciを選択してください。If you have successfully configured the recommended full UTF-8 support as described above select collation utf8mb4_unicode_ci. あなたに推奨される完全なUTF-8サポートがない場合、照合順序utf8_unicode_ciを選択してください。If you do not have the recommended full UTF-8 support select collation utf8_unicode_ci.

どのデータベースがどのMoodleに属しているか Which database belongs to which Moodle

あなたが同じサーバに複数のMoodleをインストールしている場合、あなたのMySQLサーバには複数のデータベースが存在します。If you have installed several Moodle installations on the same server, there will be several databases in your MySQL server. 例えば _mdl1 _mdl2 _mdl3 のような内容を反映していない名称かもしれません。The names might be quite poor reflections of the content like _mdl1 _mdl2 _mdl3 .では、どのデータベースがどのMoodleインストールに対応しているのか、どうやって確認できますか? So how do I see which database goes with which Moodle installation? You can go in with phpMyAdmin and in the various databases check for the table "mdl_course". There you will easily see the name of that Moodle Installation. In table mdl_config you can see the Moodle version. The main URL for the site is not in the database except where there are absolute links.

関連情報 See also