13,005
回編集
178行目: | 178行目: | ||
<br> | <br> | ||
次に、MySQLのデータディレクトリを初期化する。(MySQL 5.7.6以降、mysql_install_dbは廃止されていることに注意する)<br> | 次に、MySQLのデータディレクトリを初期化する。(MySQL 5.7.6以降、mysql_install_dbは廃止されていることに注意する)<br> | ||
<br> | |||
===== Systemdサービスの作成 ===== | |||
~/.config/systemd/userディレクトリにmysqld.serviceファイルおよびmysqld@.serviceファイルを作成する。<br> | |||
<br> | |||
# mysqld.serviceファイル | |||
[Unit] | |||
Description=MySQL Server | |||
Documentation=man:mysqld(8) | |||
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html | |||
After=network-online.target | |||
Wants=network-online.target | |||
After=syslog.target | |||
[Install] | |||
WantedBy=multi-user.target | |||
[Service] | |||
Type=notify | |||
# Disable service start and stop timeout logic of systemd for mysqld service. | |||
TimeoutSec=0 | |||
# Execute pre and post scripts as root | |||
# hence, + prefix is used | |||
# Needed to create system tables | |||
ExecStartPre=+/<MySQLのインストールディレクトリ>/bin/mysqld_pre_systemd | |||
# Start main service | |||
ExecStart=/<MySQLのインストールディレクトリ>/bin/mysqld $MYSQLD_OPTS | |||
# Use this to switch malloc implementation | |||
EnvironmentFile=-/etc/sysconfig/mysql | |||
# Sets open_files_limit | |||
LimitNOFILE = 10000 | |||
Restart=on-failure | |||
RestartPreventExitStatus=1 | |||
# Set enviroment variable MYSQLD_PARENT_PID. This is required for restart. | |||
Environment=MYSQLD_PARENT_PID=1 | |||
PrivateTmp=false | |||
PIDFile=/<MySQLのインストールディレクトリ>/tmp/mysqld.pid | |||
<br> | |||
# mysqld@.serviceファイル | |||
[Unit] | |||
Description=MySQL Server | |||
Documentation=man:mysqld(8) | |||
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html | |||
After=network-online.target | |||
Wants=network-online.target | |||
After=syslog.target | |||
[Install] | |||
WantedBy=multi-user.target | |||
[Service] | |||
Type=notify | |||
# Disable service start and stop timeout logic of systemd for mysqld service. | |||
TimeoutSec=0 | |||
# Execute pre and post scripts as root | |||
# hence, + prefix is used | |||
# Needed to create system tables | |||
ExecStartPre=+/<MySQLのインストールディレクトリ>/bin/mysqld_pre_systemd %I | |||
# Start main service | |||
ExecStart=/<MySQLのインストールディレクトリ>/bin/mysqld --defaults-group-suffix=@%I $MYSQLD_OPTS | |||
# Use this to switch malloc implementation | |||
EnvironmentFile=-/etc/sysconfig/mysql | |||
# Sets open_files_limit | |||
LimitNOFILE = 10000 | |||
Restart=on-failure | |||
RestartPreventExitStatus=1 | |||
# Set enviroment variable MYSQLD_PARENT_PID. This is required for restart. | |||
Environment=MYSQLD_PARENT_PID=1 | |||
PrivateTmp=false | |||
<br> | <br> | ||
===== MySQLの設定ファイルの作成 ===== | ===== MySQLの設定ファイルの作成 ===== | ||
206行目: | 297行目: | ||
sed -i -e "s/# default_authentication_plugin = mysql_native_password/default_authentication_plugin = mysql_native_password/g" my.cnf | sed -i -e "s/# default_authentication_plugin = mysql_native_password/default_authentication_plugin = mysql_native_password/g" my.cnf | ||
<br> | <br> | ||
===== MySQLの初期化 ===== | ===== MySQLの初期化 ===== | ||
MySQLの初期化を行う。<br> | MySQLの初期化を行う。<br> |