I have a screwed install of MySql Server on my Machine its a 10.04 64-bit Ubuntu.

I can neither Remove it or Install a new one.

I tried apt-get remove

and

dpkg --purge mysql-server-5.1

They both reach

dpkg --purge mysql-server-5.1

and stay stuck there.

Can anyone please help me completely remove the Package for a fresh install.

I installed the community managed version of MySql Server btw.

Dani AI

Generated

Brief summary for : you’ve already tried package removal and a dpkg purge and the process hangs. ’s Synaptic suggestion can be useful, but GUIs won’t help if dpkg is stuck in a maintainer script or a running mysqld process. The checklist below focuses on diagnosing the hang, forcing package removal safely, and cleaning leftover files. Back up /var/lib/mysql first if you need the data.

Try these steps in order (each block is a single command or a short sequence):

Stop the server and check for running processes:

sudo service mysql stop
ps aux | egrep 'mysql|mysqld'
sudo kill -9 <pid>   # only if a process is stubborn

Clear package locks and repair dpkg/apt state:

sudo rm -f /var/lib/dpkg/lock /var/cache/apt/archives/lock
sudo dpkg --configure -a
sudo apt-get install -f

Force-remove the broken package and purge leftovers:

sudo dpkg --remove --force-remove-reinstreq mysql-server-5.1
sudo apt-get purge mysql-server mysql-client mysql-common
sudo apt-get autoremove

If removal fails because of maintainer scripts (postinst/postrm), replace them with a no-op so dpkg can finish:

sudo mv /var/lib/dpkg/info/mysql-server-5.1.postrm /root/
sudo sh -c 'printf "%s\n" "#!/bin/sh" "exit 0" > /var/lib/dpkg/info/mysql-server-5.1.postrm'
sudo chmod +x /var/lib/dpkg/info/mysql-server-5.1.postrm
sudo dpkg --remove --force-remove-reinstreq mysql-server-5.1

Final cleanup and verification:

sudo rm -rf /var/lib/mysql /etc/mysql /var/log/mysql    # only after backup
dpkg -l | grep -i mysql

Notes and cautions: never rm -rf /var/lib/mysql until you’re certain you don’t need the data. If the package names differ (community .deb sometimes uses different names), list installed mysql packages first with dpkg -l | grep -i mysql and adapt the commands. If you hit errors, paste the exact dpkg/apt error lines — they point to the failing script or resource.

why you dont not use synapti for this ???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.