MySQL

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page MySQL and the translation is 100% complete.

MySQLは、人気のある、フリーソフトウェアのリレーショナルデータベース管理システムです。しばしばWebアプリケーション(多くのPHPサイトなど)と併せて利用されますが、1994年のスタート以来、さらにより多くのエンタープライズ・レベルの機能も獲得してきました。代替的なフォークとして、MariaDBがあります。

インストール

USE フラグ

dev-db/mysql のインストールの前に、パッケージの展開や機能に影響するUSEフラグを注意深く検討してください。以下の表は、パッケージでサポートされているUSEフラグの概要を表しています:

USE flags for dev-db/mysql Fast, multi-threaded, multi-user SQL database server

+perl Add optional support/bindings for the Perl language
+server Build the server program
cjk Add CJK support for InnoDB fulltext search using app-text/mecab
cracklib Support for cracklib strong password checking
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
jemalloc Use dev-libs/jemalloc for memory management
latin1 Use LATIN1 encoding instead of UTF8
numa Enable NUMA support using sys-process/numactl (NUMA kernel support is also required)
profiling Add support for statement profiling (requires USE=community).
router Build the MySQL router program
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
tcmalloc Use the dev-util/google-perftools libraries to replace the malloc() implementation with a possibly faster one
test Install upstream testsuites for end use.
test-install Install testsuite for manual execution by the user
verify-sig Verify upstream signatures on distfiles
Data provided by the Gentoo Package Database · Last update: 2026年06月19日 06:05 More information about USE flags

Emerge

適切なUSEフラグがセットされたら、MySQLをインストールします:

root #emerge --ask dev-db/mysql

設定

サービス

OpenRC

データベース(群)が起動時に自動的に開始されるようにするには、mysql initスクリプトをdefaultランレベルに追加します:

root #rc-update add mysql default

データベースの設定(この文書の後の方で触れます)の後、mysqlサービスを開始します:

root #rc-service mysql start

予備的な設定

dev-db/mysql パッケージは、--configオプションを通じて予備的なセットアップを処理します:

root #emerge --config dev-db/mysql

これは、データベースを作成し、それに適切な権限を設定し、またよいrootパスワード(これはMySQLのrootアカウントのためのものであり、Linuxのrootアカウントとは無関係です)の作成を支援します。

匿名ユーザーとテスト用データベースをインストールから除去するには、予備的なセットアップの後、mysql_secure_installationを実行します:

root #mysql_secure_installation

データベース内の設定

データベースが起動、実行されているときに、mysqlクライアントアプリケーションを使ってデータベースに接続します。

user $mysql -u root -p -h localhost
Enter root password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.5.1
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql>

この時点から、クエリーや点検のための管理コマンドを受け入れる、MySQLインスタンスへのセッションが開かれます。

コマンド履歴の削除

デフォルトでは、MySQLは放置された平文のパスワードを含むすべての行動を履歴ファイルに記録します。

履歴ファイルを削除するには:

root #rm /root/.mysql_history

代わりに、以下のように、履歴の記録を恒久的に無効化することもできます:

root #ln -sf /dev/null /root/.mysql_history

関連項目