「MySQL」の版間の差分

提供:MoodleDocs
移動先:案内検索
編集の要約なし
編集の要約なし
(同じ利用者による、間の27版が非表示)
1行目: 1行目:
MySQLは、Moodleインストールでサポートされているデータベースの1つです。
{{Moodleのインストール}}


MySQL自体、次のように表現されています。「MySQL ABによって、開発・配布・サポートされている、もっとも人気のあるオーップンソースのSQLデータベース管理システムです。MySQL ABは、MySQLの開発者によって創設された会社です。MySQL ABは、第2世代のオープンソース会社であり、成功したビジネスモデルにより、オープンソースの価値および手法を統合します」
再作成中です - [[利用者:Mitsuhiro Yoshida|Mitsuhiro Yoshida]] ([[利用者・トーク:Mitsuhiro Yoshida|トーク]])


MySQL describes itself as "the most popular Open Source SQL database management system, is developed, distributed, and supported by MySQL AB. MySQL AB is a commercial company, founded by the MySQL developers. It is a second generation Open Source company that unites Open Source values and methodology with a successful business model."
MySQLはMoodleのインストレーションを支えるサポートされたデータベースの1つです。


== 関連情報 ==
== MySQLをインストールする Installing MySQL ==


* [http://www.mysql.com/ MySQLホームページ]
* あなたがLinuxを使用している場合、ディストリビューションのパッケージマネージャを使用したインストールをお勧めします。これにより利用可能なアップデートを確実に入手できます。 しかし、お使いのディストリビューションによってはapt-getまたはyumも使用できます。
* [http://moodle.org/mod/forum/view.php?id=45 Using Moodleデータベースフォーラム] - 英語
* ほとんどの一般的なオペレーティングシステムに対応したインストーラが用意されています: https://dev.mysql.com/downloads/mysql/
* [http://en.wikipedia.org/wiki/MySQL Wikipedia 「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サポートを設定する Configure full UTF-8 support ===


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


{{スタブ}}
これがすでに設定されているかどうかは''mysql>''プロンプトまたはphpMyAdmin等で以下のステートメントを実行して確認してください:
<pre>SHOW GLOBAL VARIABLES WHERE variable_name IN ('innodb_file_format', 'innodb_large_prefix', 'innodb_file_per_table');</pre>


[[en: MySQL]]
[[File:phpMyAdmin1.png|alt=innodb_file_format=Barracuda;innodb_file_per_table=ON;innodb_large_prefix=ON]] or [[File:phpMyAdmin2.png|alt=innodb_file_format=(blank);innodb_file_per_table=ON;innodb_large_prefix=(blank)]] or [[File:phpMyAdmin3.png|alt=innodb_file_per_table=ON]]
 
If the settings you see match any list above then no changes are needed and you can skip to [[#Creating_Moodle_database| Creating Moodle database]].
表示された設定が上のリストと一致する場合、変更の必要はないため、[[#Moodleデータベースを作成する|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'''.
 
* Note: Back up the configuration file before changing it.
* 注意: 設定ファイルを変更する前にバックアップを取ってください。
* Note: Back up all databases before making this change.
* 注意: この変更の前にすべてのデータベースをバックアップしてください。
* Note: Other systems with databases on this server may be impacted by this change.
* 注意: このサーバでデータベースを利用する他のシステムはこの変更により影響を受ける可能性があります。
 
Add the following settings to the configuration file, do not add '''innodb_file_format = Barracuda''' and '''innodb_large_prefix = 1''' if these were blank or missing when you ran '''SHOW GLOBAL VARIABLES''' above:
<pre>[client]
default-character-set = utf8mb4
 
[mysqld]
innodb_file_format = Barracuda  # Remove line if not needed
innodb_file_per_table = 1
innodb_large_prefix = 1          # Remove line if not needed
 
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
skip-character-set-client-handshake
 
[mysql]
default-character-set = utf8mb4</pre>
 
Restart the MySQL server process to apply these settings (for example with MariaDB on Linux: '''systemctl restart mariadb''').
 
If you have any difficulty applying these settings, see [[MySQL_full_unicode_support]] for further information.
 
If for some reason you cannot change to the settings described here you can continue to install Moodle but you must select '''utf8''' and '''utf8_unicode_ci''' for the default character set and collation respectively.
 
== 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.
 
The instructions assume that the web server and MySQL server are on the same machine. In this case the 'dbhost' is '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.
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
<pre>
$ mysql -u root -p
Enter password:
</pre>
(Enter the password you previously set - or been given - for the MySQL 'root' user). After some pre-amble this should take you to the ''mysql>'' prompt.
* Create a new database (called 'moodle' - substitute your own name if required).
If you have successfully configured the recommended full UTF-8 support as described above run:
<pre>
mysql> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
</pre>
If you do not have the recommended full UTF-8 support run:
<pre>mysql> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;</pre>
* Add a user/password with the minimum needed permissions:
<pre>
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;
</pre>
...which creates a user called 'moodleuser' with a password 'yourpassword'. Make sure you invent a strong password and resist the temptation to 'GRANT ALL'.
* Exit from mysql:
<pre>
mysql> quit
</pre>
 
=== phpMyAdmin ===
 
[http://www.phpmyadmin.net/ phpMyAdmin] is a web based administration tool for MySQL. If this is available you can use it to create a new database. If you have successfully configured the recommended full UTF-8 support as described above select collation '''utf8mb4_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==
If you have installed several Moodle installations on the same server, there will be several databases in your MySQL server. The names might be quite poor reflections of the content like  _mdl1 _mdl2 _mdl3 . 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 ==
 
* [[MariaDB]]
* [[MySQL full unicode support]]
* [http://www.mysql.com/ The MySQL homepage]
* [http://en.wikipedia.org/wiki/MySQL Wikipedia article about ''MySQL'']
* [http://forums.mysql.com/read.php?24,92131,92131 List of articles on MySQL performance tuning]
 
[[Category:SQL databases]]
 
[[en:MySQL]]
[[de:MySQL]]
[[es:MySQL]]

2024年5月20日 (月) 15:01時点における版


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

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

MySQLをインストールする Installing 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サポートを設定する Configure full UTF-8 support

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

If the settings you see match any list above then no changes are needed and you can skip to Creating Moodle database. 表示された設定が上のリストと一致する場合、変更の必要はないため、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.

  • Note: Back up the configuration file before changing it.
  • 注意: 設定ファイルを変更する前にバックアップを取ってください。
  • Note: Back up all databases before making this change.
  • 注意: この変更の前にすべてのデータベースをバックアップしてください。
  • Note: Other systems with databases on this server may be impacted by this change.
  • 注意: このサーバでデータベースを利用する他のシステムはこの変更により影響を受ける可能性があります。

Add the following settings to the configuration file, do not add innodb_file_format = Barracuda and innodb_large_prefix = 1 if these were blank or missing when you ran SHOW GLOBAL VARIABLES above:

[client]
default-character-set = utf8mb4

[mysqld]
innodb_file_format = Barracuda   # Remove line if not needed
innodb_file_per_table = 1
innodb_large_prefix = 1          # Remove line if not needed

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

[mysql]
default-character-set = utf8mb4

Restart the MySQL server process to apply these settings (for example with MariaDB on Linux: systemctl restart mariadb).

If you have any difficulty applying these settings, see MySQL_full_unicode_support for further information.

If for some reason you cannot change to the settings described here you can continue to install Moodle but you must select utf8 and utf8_unicode_ci for the default character set and collation respectively.

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.

The instructions assume that the web server and MySQL server are on the same machine. In this case the 'dbhost' is '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. 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 -u root -p
Enter password: 

(Enter the password you previously set - or been given - for the MySQL 'root' user). After some pre-amble this should take you to the mysql> prompt.

  • Create a new database (called 'moodle' - substitute your own name if required).

If you have successfully configured the recommended full UTF-8 support as described above run:

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

If you do not have the recommended full UTF-8 support run:

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'.

  • Exit from mysql:
mysql> quit

phpMyAdmin

phpMyAdmin is a web based administration tool for MySQL. If this is available you can use it to create a new database. If you have successfully configured the recommended full UTF-8 support as described above select collation utf8mb4_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

If you have installed several Moodle installations on the same server, there will be several databases in your MySQL server. The names might be quite poor reflections of the content like _mdl1 _mdl2 _mdl3 . 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