FreeBSD 14.0 RELEASE - MySQL - 設定
1. 概要 コンフィグレーションファイルは、「/usr/local/etc/mysql/my.cnf」です。 デフォルトは以下のように書かれています。 [client] port = 3306 socket = /tmp/mysql.sock [mysql] prompt = \u@\h [\d]>\_ no_auto_rehash [mysqld] user = mysql port = 3306 socket = /tmp/mysql.sock bind-address = 127.0.0.1 basedir = /usr/local datadir = /var/db/mysql tmpdir = /var/db/mysql_tmpdir replica-load-tmpdir = /var/db/mysql_tmpdir secure-file-priv = /var/db/mysql_secure log-bin = mysql-bin log-output = TABLE relay-log-recovery = 1 slow-query-log = 1 server-id = 1 sync_binlog = 1 sync_relay_log = 1 binlog_cache_size = 16M binlog_expire_logs_seconds = 2592000 default_password_lifetime = 0 enforce-gtid-consistency = 1 gtid-mode = ON safe-user-create = 1 lower_case_table_names = 1 explicit-defaults-for-timestamp = 1 myisam-recover-options = BACKUP,FORCE open_files_limit = 32768 table_open_cache = 16384 table_definition_cache = 8192 net_retry_count = 16384 key_buffer_size = 256M max_allowed_packet = 64M long_query_time = 0.5 innodb_buffer_pool_size = 1G innodb_data_home_dir = /var/db/mysql innodb_log_group_home_dir = /var/db/mysql innodb_data_file_path = ibdata1:128M:autoextend innodb_temp_data_file_path = ibtmp1:128M:autoextend innodb_flush_method = O_DIRECT innodb_redo_log_capacity = 512M innodb_log_buffer_size = 16M innodb_write_io_threads = 8 innodb_read_io_threads = 8 innodb_autoinc_lock_mode = 2 [mysqldump] max_allowed_packet = 256M quote_names quick 2. プロンプトを変更する プロンプトが ユーザ名@localhost [(none)]> となってて、わたしは前のままがいいのです。 prompt = \u@\h [\d]>\_ の行を削除するなり、コメントアウトするなりすれば mysql> に戻ります。 3. 文字コードを設定 日本語を扱うのであれば、今はぜひ、「UTF-8」を使用するべきであるし。 「UTF-8」を使用するのであれば。 「root」ユーザ権限で。 vi /usr/local/etc/mysql/my.cnf 必ず文字コードの設定を書いておきましょう。 [mysqld] のセクション内に、下記の1行を追加します。 character-set-server = utf8 変更した場合は service mysql-server restart
[client] port = 3306 socket = /tmp/mysql.sock [mysql] prompt = \u@\h [\d]>\_ no_auto_rehash [mysqld] user = mysql port = 3306 socket = /tmp/mysql.sock bind-address = 127.0.0.1 basedir = /usr/local datadir = /var/db/mysql tmpdir = /var/db/mysql_tmpdir replica-load-tmpdir = /var/db/mysql_tmpdir secure-file-priv = /var/db/mysql_secure log-bin = mysql-bin log-output = TABLE relay-log-recovery = 1 slow-query-log = 1 server-id = 1 sync_binlog = 1 sync_relay_log = 1 binlog_cache_size = 16M binlog_expire_logs_seconds = 2592000 default_password_lifetime = 0 enforce-gtid-consistency = 1 gtid-mode = ON safe-user-create = 1 lower_case_table_names = 1 explicit-defaults-for-timestamp = 1 myisam-recover-options = BACKUP,FORCE open_files_limit = 32768 table_open_cache = 16384 table_definition_cache = 8192 net_retry_count = 16384 key_buffer_size = 256M max_allowed_packet = 64M long_query_time = 0.5 innodb_buffer_pool_size = 1G innodb_data_home_dir = /var/db/mysql innodb_log_group_home_dir = /var/db/mysql innodb_data_file_path = ibdata1:128M:autoextend innodb_temp_data_file_path = ibtmp1:128M:autoextend innodb_flush_method = O_DIRECT innodb_redo_log_capacity = 512M innodb_log_buffer_size = 16M innodb_write_io_threads = 8 innodb_read_io_threads = 8 innodb_autoinc_lock_mode = 2 [mysqldump] max_allowed_packet = 256M quote_names quick
ユーザ名@localhost [(none)]>
prompt = \u@\h [\d]>\_
mysql>
vi /usr/local/etc/mysql/my.cnf
[mysqld]
character-set-server = utf8
service mysql-server restart