diff --git a/plugins/mysql-apt/index.py b/plugins/mysql-apt/index.py index dbb203677..ec0d97998 100755 --- a/plugins/mysql-apt/index.py +++ b/plugins/mysql-apt/index.py @@ -262,6 +262,7 @@ def initMysql57Data(): serverdir = getServerDir() myconf = serverdir + "/etc/my.cnf" user = pGetDbUser() + cmd = 'mysqld --defaults-file=' + myconf + \ ' --initialize-insecure --explicit_defaults_for_timestamp' mw.execShell(cmd) @@ -270,12 +271,23 @@ def initMysql57Data(): def initMysql8Data(): + ''' + chmod 644 /www/server/mysql-apt/etc/my.cnf + try: + mysqld --basedir=/usr --datadir=/www/server/mysql-apt/data --initialize-insecure + mysqld --defaults-file=/www/server/mysql-apt/etc/my.cnf --initialize-insecure + mysqld --initialize-insecure + ''' datadir = getDataDir() if not os.path.exists(datadir + '/mysql'): serverdir = getServerDir() user = pGetDbUser() + cmd = 'mysqld --basedir=/usr --datadir=' + datadir + ' --initialize-insecure' - mw.execShell(cmd) + data = mw.execShell(cmd) + if data[1].find('ERROR') != -1: + exit("Init MySQL{} Data Error".format(8)) + mw.execShell('chown -R mysql mysql ' + getServerDir()) return False return True diff --git a/plugins/mysql-apt/init.d/mysql.service.tpl b/plugins/mysql-apt/init.d/mysql.service.tpl index 8aa912c37..a068c3716 100644 --- a/plugins/mysql-apt/init.d/mysql.service.tpl +++ b/plugins/mysql-apt/init.d/mysql.service.tpl @@ -1,63 +1,50 @@ -# It's not recommended to modify this file in-place, because it will be -# overwritten during package upgrades. If you want to customize, the -# best way is to use systemctl edit: +# Copyright (c) 2015, 2022, Oracle and/or its affiliates. # -# $ systemctl edit mysqld.service +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License, version 2.0, +# as published by the Free Software Foundation. # -# this will create file +# This program is also distributed with certain software (including +# but not limited to OpenSSL) that is licensed under separate terms, +# as designated in a particular file or component or in included license +# documentation. The authors of MySQL hereby grant you an additional +# permission to link the program and your derivative works with the +# separately licensed software that they have included with MySQL. # -# /etc/systemd/system/mysqld.service.d/override.conf +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License, version 2.0, for more details. # -# which be parsed after the file mysqld.service itself is parsed. -# -# For example, if you want to increase mysql's open-files-limit to 20000 -# add following when editing with command above: -# -# [Service] -# LimitNOFILE=20000 -# -# Or if you require to execute pre and post scripts in the unit file as root, set -# PermissionsStartOnly=true -# -# For more info about custom unit files, see systemd.unit(5) or -# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F -# -# Don't forget to reload systemd daemon after you change unit configuration: -# root> systemctl --system daemon-reload +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# MySQL systemd service file [Unit] -Description=MySQL 8.0 database server -After=syslog.target +Description=MySQL Community Server +Documentation=man:mysqld(8) +Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target +[Install] +WantedBy=multi-user.target + [Service] -Type=notify User=mysql Group=mysql - -ExecStartPre=/usr/libexec/mysql-check-socket -ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n -# Note: we set --basedir to prevent probes that might trigger SELinux alarms, -# per bug #547485 -ExecStart=/usr/libexec/mysqld --defaults-file={$SERVER_PATH}/mysql-ya/etc/my.cnf --basedir=/usr --user=mysql -ExecStartPost=/usr/libexec/mysql-check-upgrade -ExecStopPost=/usr/libexec/mysql-wait-stop - -# Give a reasonable amount of time for the server to start up/shut down -TimeoutSec=300 - -# Place temp files in a secure directory, not /tmp -PrivateTmp=false - +Type=notify +ExecStartPre=+/usr/share/mysql-8.0/mysql-systemd-start pre +ExecStart=/usr/sbin/mysqld +TimeoutSec=0 +LimitNOFILE = 10000 Restart=on-failure - RestartPreventExitStatus=1 -# Sets open_files_limit -LimitNOFILE = 10000 +# Always restart when mysqld exits with exit code of 16. This special exit code +# is used by mysqld for RESTART SQL. +RestartForceExitStatus=16 -# Set enviroment variable MYSQLD_PARENT_PID. This is required for SQL restart command. +# Set enviroment variable MYSQLD_PARENT_PID. This is required for restart. Environment=MYSQLD_PARENT_PID=1 - -[Install] -WantedBy=multi-user.target