[packages/mysql] - update init scripts and related stuff
arekm
arekm at pld-linux.org
Thu Oct 22 15:23:12 CEST 2015
commit 874af6dea26c9ea8027718dfb18a711c037a6028
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Oct 22 15:23:05 2015 +0200
- update init scripts and related stuff
mysql.init | 66 +++++++++++++++++++++----------------------------------------
mysql.spec | 45 ++++++++++++++++++++++++++++++++++++++---
mysqld.conf | 5 ++---
3 files changed, 66 insertions(+), 50 deletions(-)
---
diff --git a/mysql.spec b/mysql.spec
index ec2e341..38f6707 100644
--- a/mysql.spec
+++ b/mysql.spec
@@ -563,7 +563,7 @@ CPPFLAGS="%{rpmcppflags}" \
%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,sysconfig,mysql,skel} \
- $RPM_BUILD_ROOT/var/{log/{archive,}/mysql,lib/mysql} \
+ $RPM_BUILD_ROOT/var/{log/{archive,}/mysql,lib/{mysql,mysql-files}} \
$RPM_BUILD_ROOT%{_mysqlhome} \
$RPM_BUILD_ROOT%{_libdir}
@@ -860,6 +860,45 @@ for config in $configs; do
done
) | %banner -e %{name}-5.5
+%triggerpostun -- mysql < 5.7.0
+configs=""
+for config in $(awk -F= '!/^#/ && /=/{print $1}' /etc/%{name}/clusters.conf); do
+ if echo "$config" | grep -q '^/'; then
+ config_file="$config"
+ elif [ -f "/etc/%{name}/$config" ]; then
+ config_file=/etc/%{name}/$config
+ else
+ clusterdir=$(awk -F= "/^$config/{print \$2}" /etc/%{name}/clusters.conf)
+ if [ -z "$clusterdir" ]; then
+ echo >&2 "Can't find cluster dir for $config!"
+ echo >&2 "Please remove extra (leading) spaces from /etc/%{name}/clusters.conf"
+ exit 1
+ fi
+ config_file="$clusterdir/mysqld.conf"
+ fi
+
+ if [ ! -f "$config_file" ]; then
+ echo >&2 "ERROR: Can't find real config file for $config! Please report this (with above errors, if any) to http://bugs.pld-linux.org/"
+ continue
+ fi
+ configs="$configs $config_file"
+done
+
+(
+echo 'You should run MySQL upgrade script *after* restarting MySQL server for all MySQL clusters.'
+echo 'Thus, you should invoke:'
+for config in $configs; do
+ sed -i -e '
+ s/^log-warnings *=/log-error-verbosity =/
+ s/^myisam-recover$/myisam-recover-options/
+ s/^innodb_mirrored_log_groups.*//
+ ' $config
+
+ socket=$(awk -F= '!/^#/ && $1 ~ /socket/{print $2}' $config | xargs)
+ echo "# mysql_upgrade ${socket:+--socket=$socket}"
+done
+) | %banner -e %{name}-5.7
+
%files
%defattr(644,root,root,755)
%doc build/support-files/*.cnf
@@ -872,7 +911,6 @@ done
%attr(755,root,root) %{_sbindir}/myisamchk
%attr(755,root,root) %{_sbindir}/myisamlog
%attr(755,root,root) %{_sbindir}/myisampack
-#%attr(755,root,root) %{_sbindir}/mysql_fix_privilege_tables
%attr(755,root,root) %{_sbindir}/mysql_plugin
%attr(755,root,root) %{_sbindir}/mysql_upgrade
%attr(755,root,root) %{_sbindir}/mysqlcheck
@@ -905,7 +943,6 @@ done
%{_mandir}/man1/myisamchk.1*
%{_mandir}/man1/myisamlog.1*
%{_mandir}/man1/myisampack.1*
-#%{_mandir}/man1/mysql_fix_privilege_tables.1*
%{_mandir}/man1/mysql_plugin.1*
%{_mandir}/man1/mysql_upgrade.1*
%{_mandir}/man1/mysqlcheck.1*
@@ -920,6 +957,8 @@ done
%attr(700,mysql,mysql) %{_mysqlhome}
# root:root is proper here for mysql.rpm while mysql:mysql is potential security hole
%attr(751,root,root) /var/lib/mysql
+# https://dev.mysql.com/doc/refman/5.7/en/server-options.html#option_mysqld_secure-file-priv
+%attr(770,mysql,mysql) /var/lib/mysql-files
%attr(750,mysql,mysql) %dir /var/log/mysql
%attr(750,mysql,mysql) %dir /var/log/archive/mysql
%attr(640,mysql,mysql) %ghost /var/log/mysql/*
diff --git a/mysql.init b/mysql.init
index 62d68e2..6b1da9b 100755
--- a/mysql.init
+++ b/mysql.init
@@ -51,7 +51,7 @@ else
exit 0
fi
-sharedir=/usr/share/percona-server
+sharedir=/usr/share/mysql
action="$1"
@@ -465,7 +465,7 @@ mysqlinit() {
exit 6
fi
- show "Installing MySQL system tables for $MYSQL_DATA_DIR"
+ show "Initializing MySQL database for $MYSQL_DATA_DIR"
busy
TMP=/tmp TMPDIR=/tmp
@@ -486,81 +486,59 @@ mysqlinit() {
chmod 640 "$MYSQL_CLUSTER_DIR/mysqld.conf"
fi
- cat > $MYSQL_DATA_DIR/mysql-init.sql <<-EOF
- CREATE DATABASE mysql;
- use mysql;
- $(cat $sharedir/mysql_system_tables.sql)
- $(sed -e "/@current_hostname/d" $sharedir/mysql_system_tables_data.sql)
-EOF
-
ok=0
/usr/sbin/mysqld \
--defaults-file=$MYSQL_CLUSTER_DIR/mysqld.conf \
- --bootstrap \
+ --initialize \
--skip-grant-tables \
--datadir=$MYSQL_DATA_DIR \
--user=$MYSQL_USER \
--slave-load-tmpdir=$MYSQL_DATA_DIR \
--tmpdir=$MYSQL_DATA_DIR \
--log-error=$MYSQL_ERRLOG \
- < $MYSQL_DATA_DIR/mysql-init.sql && ok=1
+ && ok=1
[ -f $MYSQL_DATA_DIR/mysql/user.frm ] || ok=0
if [ "$ok" = 1 ]; then
- rm -f $MYSQL_DATA_DIR/mysql-init.sql
ok
cat << END_OF_MSG
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL USERS!
-This is done, after starting database, in the order shown,
-with:
-For 'mysql_sysadmin' (RELOAD and SHUTDOWN privileges):
+CURRENT TEMPORARY ROOT PASSWORD CAN BE FOUND IN LOG
+(grep for "A temporary password is generated" string):
+$MYSQL_ERRLOG
+
+
+Start database:
+$ service mysql start
+
+and set passwords:
+
+FIXME FIXME: For 'mysql_sysadmin' (RELOAD and SHUTDOWN privileges):
echo "update mysql.user set password=password('newpassword') where user='mysql_sysadmin'; FLUSH PRIVILEGES;" | mysql -u mysql -S $MYSQL_SOCKET
-For 'mysql' user (ALL privileges, DB admin):
-echo "update mysql.user set password=password('newpassword') where user='mysql'; FLUSH PRIVILEGES;" | mysql -u mysql -S $MYSQL_SOCKET
+For 'root' user (ALL privileges, DB admin), paste command with new password:
+ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword'; FLUSH PRIVILEGES;
+
+into command:
+$ mysql -u root -p -S $MYSQL_SOCKET
NOTE: mysql_sysadmin password should be placed to $MYSQL_CONFIG in
mysqladmin section. See the manual for more instructions.
(This user is used at logs rotation and server shutdown)
END_OF_MSG
- show "Filling help tables..."
- ok=0
- ( echo "use mysql;"; cat $sharedir/fill_help_tables.sql ) | \
- /usr/sbin/mysqld \
- --defaults-file=$MYSQL_CLUSTER_DIR/mysqld.conf \
- --bootstrap \
- --skip-grant-tables \
- --datadir=$MYSQL_DATA_DIR \
- --user=$MYSQL_USER \
- --slave-load-tmpdir=$MYSQL_DATA_DIR \
- --tmpdir=$MYSQL_DATA_DIR \
- --log-error=$MYSQL_ERRLOG \
- && ok=1
- if [ "$ok" = 1 ]; then
- ok
- else
- cat << END_OF_MSG
-
-WARNING: HELP FILES ARE NOT COMPLETELY INSTALLED!
-The "HELP" command might not work properly.
-
-END_OF_MSG
- fi
else
fail
cat << END_OF_MSG
ERROR:
ERROR:
-ERROR: Installation of grant tables FAILED!
+ERROR: Installation FAILED!
ERROR:
ERROR:
-The initialization SQL script was preserved at $MYSQL_DATA_DIR/mysql-init.sql
-
-Examine the logs in /var/log/mysql for more information. You can
+Examine the logs in $MYSQL_ERRLOG for more information. You can
also try to start the mysqld daemon with:
/usr/sbin/mysqld --skip-grant &
diff --git a/mysqld.conf b/mysqld.conf
index 6320c07..aee7357 100644
--- a/mysqld.conf
+++ b/mysqld.conf
@@ -126,7 +126,7 @@ log-output = FILE
# mysqld error log (stderr)
log-error = /var/log/mysql/mysqld.log
-log-warnings = 2
+log-error-verbosity = 2
# Log slow queries
slow-query-log
@@ -197,7 +197,7 @@ slow-query-log-file = /var/log/mysql/slow.log
#delay-key-write-for-all-tables
# Repair automatically on open if the table wasn't closed properly.
-myisam-recover
+myisam-recover-options
#
#myisam_sort_buffer_size=4M
@@ -219,7 +219,6 @@ innodb_file_per_table
# these are actual defaults (as of 5.0.26)
innodb_data_home_dir = @clusterdir@/mysqldb/db
innodb_data_file_path = ibdata1:10M:autoextend
-innodb_mirrored_log_groups=1
innodb_log_group_home_dir = @clusterdir@/mysqldb/db
innodb_log_files_in_group=2
innodb_log_file_size=5M
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/mysql.git/commitdiff/874af6dea26c9ea8027718dfb18a711c037a6028
More information about the pld-cvs-commit
mailing list