卸载Mariadb-报错

1. rpm -qa|grep aria

MariaDB-client-10.1.22-1.x86_64
MariaDB-devel-10.1.22-1.x86_64
MariaDB-shared-10.1.22-1.x86_64
MariaDB-cracklib-password-check-10.1.22-1.x86_64
MariaDB-common-10.1.22-1.x86_64
MariaDB-server-10.1.22-1.x86_64

2. rpm -e  `rpm -qa|grep aria`

redirecting to systemctl stop mysql.service
Usage:
insserv [[-r] <script>]

Options:
--remove, -r
Remove the listed scripts from all runlevels

/sbin/insserv failed, exit code 1

Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.

If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.

mysql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
error: %preun(MariaDB-server-10.1.22-1.x86_64) scriptlet failed, exit status 1
error: MariaDB-server-10.1.22-1.x86_64: erase failed

 

3.查看依赖:

rpm -q -scripts MariaDB-server-10.1.22-1.x86_64

 

preinstall scriptlet (using /bin/sh):
# Check if we can safely upgrade. An upgrade is only safe if it's from one
# of our RPMs in the same version family.

installed=`rpm -q --whatprovides mysql-server 2> /dev/null`
if [ $? -eq 0 -a -n "$installed" ]; then
installed=`echo "$installed"|sed -n 1p`
vendor=`rpm -q --queryformat='%{VENDOR}' "$installed" 2>&1`
version=`rpm -q --queryformat='%{VERSION}' "$installed" 2>&1`
myvendor='Monty Program AB'
myversion='10.1.22'

old_family=`echo $version | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`
new_family=`echo $myversion | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`

[ -z "$vendor" ] && vendor='<unknown>'
[ -z "$old_family" ] && old_family="<unrecognized version $version>"
[ -z "$new_family" ] && new_family="<bad package specification: version $myversion>"

error_text=
if [ "$vendor" != "$myvendor" ]; then
error_text="$error_text
The current MariaDB server package is provided by a different
vendor ($vendor) than $myvendor. Some files may be installed
to different locations, including log files and the service
startup script in /etc/init.d/.
"
fi

if [ "$old_family" != "$new_family" ]; then
error_text="$error_text
Upgrading directly from MySQL $old_family to MariaDB $new_family may not
be safe in all cases. A manual dump and restore using mysqldump is
recommended. It is important to review the MariaDB manual's Upgrading
section for version-specific incompatibilities.
"
fi

if [ -n "$error_text" ]; then
cat <<HERE >&2

******************************************************************
A MySQL or MariaDB server package ($installed) is installed.
$error_text
A manual upgrade is required.

- Ensure that you have a complete, working backup of your data and my.cnf
files
- Shut down the MySQL server cleanly
- Remove the existing MySQL packages. Usually this command will
list the packages you should remove:
rpm -qa | grep -i '^mysql-'

You may choose to use 'rpm --nodeps -ev <package-name>' to remove
the package which contains the mysqlclient shared library. The
library will be reinstalled by the MariaDB-shared package.
- Install the new MariaDB packages supplied by $myvendor
- Ensure that the MariaDB server is started
- Run the 'mysql_upgrade' program

This is a brief description of the upgrade process. Important details
can be found in the MariaDB manual, in the Upgrading section.
******************************************************************
HERE
exit 1
fi
fi
postinstall scriptlet (using /bin/sh):
if [ -f /usr/lib/systemd/system/mariadb.service -a -x /usr/bin/systemctl ]; then
systemd_conf=/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
if [ -x /usr/bin/mariadb-service-convert -a ! -f "${systemd_conf}" ]; then
# Either fresh install or upgrade non-systemd -> systemd
mkdir -p /etc/systemd/system/mariadb.service.d
/usr/bin/mariadb-service-convert > "${systemd_conf}"
# Make sure old possibly non-systemd instance is down
if [ $1 = 2 ]; then
SYSTEMCTL_SKIP_REDIRECT=1 /etc/init.d/mysql stop >/dev/null 2>&1 || :
systemctl start mariadb >/dev/null 2>&1 || :
fi
systemctl enable mariadb.service >/dev/null 2>&1 || :
fi
fi

# Make MySQL start/shutdown automatically when the machine does it.
if [ $1 = 1 ] ; then
if [ -x /usr/bin/systemctl ] ; then
/usr/bin/systemctl daemon-reload >/dev/null 2>&1
fi

if [ -x /sbin/chkconfig ] ; then
/sbin/chkconfig --add mysql
fi

basedir=`/usr/bin/my_print_defaults --mysqld|sed -ne 's/^--basedir=//p'|tail -1`
if [ -z "$basedir" ] ; then
basedir=/usr
fi

datadir=`/usr/bin/my_print_defaults --mysqld|sed -ne 's/^--datadir=//p'|tail -1`
if [ -z "$datadir" ] ; then
datadir=/var/lib/mysql
else
# datadir may be relative to a basedir!
if ! expr $datadir : / > /dev/null; then
datadir=$basedir/$datadir
fi
fi

# Create a MySQL user and group. Do not report any problems if it already
# exists.
groupadd -r mysql 2> /dev/null || true
useradd -M -r --home $datadir --shell /sbin/nologin --comment "MySQL server" --gid mysql mysql 2> /dev/null || true
# The user may already exist, make sure it has the proper group nevertheless (BUG#12823)
usermod --gid mysql mysql 2> /dev/null || true

# Temporary Workaround for MDEV-11386 - will be corrected in Advance Toolchain 10.0-3 and 8.0-8
for ldconfig in /opt/at*/sbin/ldconfig; do
test -x $ldconfig && $ldconfig
done

# Change permissions so that the user that will run the MySQL daemon
# owns all database files.
chown -R mysql:mysql $datadir

if [ ! -e $datadir/mysql ]; then
# Create data directory
mkdir -p $datadir/{mysql,test}

# Initiate databases
/usr/bin/mysql_install_db --rpm --user=mysql
fi

# Change permissions again to fix any new files.
chown -R mysql:mysql $datadir

# Fix permissions for the permission database so that only the user
# can read them.
chmod -R og-rw $datadir/mysql
fi

# install SELinux files - but don't override existing ones
SETARGETDIR=/etc/selinux/targeted/src/policy
SEDOMPROG=$SETARGETDIR/domains/program
SECONPROG=$SETARGETDIR/file_contexts/program

if [ -x /usr/sbin/semodule ] ; then
/usr/sbin/semodule -i /usr/share/mysql/policy/selinux/mariadb.pp
fi

if [ -x sbin/restorecon ] ; then
sbin/restorecon -R var/lib/mysql
fi
preuninstall scriptlet (using /bin/sh):
if [ $1 = 0 ] ; then
# Stop MySQL before uninstalling it
if [ -x /etc/init.d/mysql ] ; then
/etc/init.d/mysql stop > /dev/null
fi
# Don't start it automatically anymore
if [ -x /sbin/chkconfig ] ; then
/sbin/chkconfig --del mysql
fi
fi

# We do not remove the mysql user since it may still own a lot of
# database files.
postuninstall scriptlet (using /bin/sh):
if [ $1 -ge 1 ]; then
if [ -x /etc/init.d/mysql ] ; then
# only restart the server if it was alredy running
if /etc/init.d/mysql status > /dev/null 2>&1; then
/etc/init.d/mysql restart
fi
fi
fi

if [ $1 = 0 ] ; then
if [ -x /usr/bin/systemctl ] ; then
/usr/bin/systemctl daemon-reload > /dev/null 2>&1
fi
fi

 

4.最后一步,删除MariaDB-server:

rpm -e --noscripts MariaDB-server-10.1.22-1.x86_64

 

参考:http://blog.chinaunix.net/uid-631981-id-3787314.html

 

posted on 2017-10-04 13:34  天涯飞鸿  阅读(1415)  评论(0编辑  收藏  举报

导航