Databases Reference
In-Depth Information
Uninstalling MySQL
You can generally install a newer software package over an older one by using the
rpm --upgrade
,
urpmi
,
yum update
, or
apt-get install
commands described earlier. If,
you actually want to remove a package altogether rather than upgrading it, you should
first type
su -
to log in as the root user, and then execute the appropriate uninstall
commands.
Note that the data directory that contains your database files is not actually installed
but created after installation. This is typically the directory
data
under the MySQL base
directory, or
/var/lib/mysql
for a Linux distribution package installation. Uninstalling
MySQL packages does not delete this directory, so the files containing your data should
remain in place, unchanged.
For an RPM-based system such as Red Hat, Fedora, or Mandriva, use the
rpm --erase
command to uninstall specific packages. If you're unsure what the exact
package names are, you can use the
rpm --query --all
command to list all the installed
RPM packages, together with the
grep --ignore-case
command to show only those
with “mysql” (in uppercase or lowercase letters) in their name:
$
rpm --query --all | grep --ignore-case mysql
perl-DBD-mysql-3.0004-1mdv2007.0
MySQL-5.0.23-1mdv2007.0
libmysql15-5.0.23-1mdv2007.0
MySQL-client-5.0.23-1mdv2007.0
php-mysql-5.1.4-3mdv2007.0
MySQL-common-5.0.23-1mdv2007.0
Note that the
.rpm
file extension is not considered to be part of the package name. To
uninstall RPM packages, you use the
rpm
command with the
--erase
option, and list
the packages to remove. For example, you'd type (all on one line):
#
rpm --erase \
perl-DBD-mysql-3.0004-1mdv2007.0 \
MySQL-5.0.23-1mdv2007.0 \
libmysql15-5.0.23-1mdv2007.0 \
MySQL-client-5.0.23-1mdv2007.0 \
php-mysql-5.1.4-3mdv2007.0 \
MySQL-common-5.0.23-1mdv2007.0
You can query and remove the packages in one go by using the
xargs
command:
#
rpm --query --all | grep --ignore-case mysql | xargs rpm --erase
warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave
#
On a Red Hat or Fedora system with
yum
, you can also use the
yum remove
command:
#
yum remove mysql
[root@saiedpc yum.repos.d]# yum remove mysql
...
Dependencies Resolved