exit 0
fi
-sharedir=/usr/share/percona-server
+sharedir=/usr/share/mysql
action="$1"
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
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 &
%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}
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
%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
%{_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*
%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/*