Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I was surprised to find that one of my privileged users installed MySQL on a linux box. The server (mysqld) is running and doing nothing. My skills are all in Oracle, so I am unfamiliar with how to shutdown and remove the MySQL installation.

share|improve this question

6 Answers 6

up vote 13 down vote accepted

You didn't mention what distribution you are using, but if they installed it via yum on a RedHat based distribution you can remove with:

yum remove mysql-server

If they installed it in their own user space you would just remove the binary files that are running the server. If it is on Debian/Ubuntu you would use the method sparks mentioned. I would also alternatively use:

killall mysqld; killall mysqld_safe
share|improve this answer
4  
It's a good idea to get into the habit of using pkill instead of killall. You may end up on a Solaris box someday :) –  MikeyB Oct 13 '09 at 21:22
4  
I prefer /sbin/service mysql stop. Then you can chkconfig mysql off to disable it from restarting. Then the failsafe way to remove from RPM based distros (as root) rpm -qa | grep mysql, then rpm -e mysql-<package_name>. –  churnd Oct 14 '09 at 11:08
    
pkill mysqld; pkill mysqld_safe worked wonderfully. Trying killall mysqld; killall mysqld_safe was not successful. On Fedora 18 I had success with pkill, thanks MikeyB. –  RyanMichael Feb 7 '13 at 9:08

It all depends on how the original user installed the package. If they used the operating system's built in package management, it should be as easy as the yum line in Dave's answer or on a Debian-based system (including Ubuntu), you can use:

apt-get remove mysql-server

(As an aside, use purge instead of remove if you also want to remove custom configuration files)

If you don't know the exact package name to remove on Ubuntu:

dpkg -l|grep mysql

If the user in question did not use a package management tool, then the only real solution is to simply ensure that the server doesn't load on startup (chkconfig or update-rc.d are two handy tools for that -- check their man pages) and manually remove all the installed files.

share|improve this answer
    
Whoops, sorry for the redundant ubuntu answer -- leaving it in for the chkconfig and update-rc.d suggestion...) –  user19804 Oct 14 '09 at 2:46
    
Make sure to remove GUI tools/workbench also in case that's installed: sudo apt-get remove mysql-workbench –  paul_sns Sep 12 '12 at 2:13

If the user happened to set up any databases, you might need to remove those as well. In package base installation of MySQL, the table files can be found in /var/lib/mysql. If they are elsewhere, you can just search for the table files. They will have a .frm extension, and should be contained in a directory named after the database they are associated with.

share|improve this answer

Depending on your distribution you should have the option to shut it down with an init script in "/etc/init.d/mysql stop". If this fails you can kill the processes with something similar to "for i in ps -ef |grep mysqld |awk '{print $2}'; do kill -9 $i; done"

It will really be dependent on how they installed it for how you removed it. If you are running a debian based distribution: "sudo apt-get remove mysqld"

Per Zoredache's comment you can also do:"sudo apt-get purge mysqld" which would also remove configuration files.

share|improve this answer
1  
You might want 'apt-get purge' instead of remove if you want to completely git rid of everything. The package name is probably going to be 'mysql-server' and 'mysql-common' and not mysqld. –  Zoredache Oct 13 '09 at 18:41

Maybe the user himself doesn't know that he installed mysql. It can happen if mysql is a dependency of some other program. Have a look at the package manager logfile, ex: for a redhat check /var/log/yum.log. You will probably find some more packages installed at the same time. You can then deduce what the user wanted to do, and maybe you also want to remove some other packages too that you weren't aware of the installation!

On a recent redhat you can for example run "yum history list", then after you found the date of installation in /var/log/yum.log, you can deduce which yum operation was related to the mysql installation, and you can for example "yum history info operation_number" to get details of the installation, or "yum history undo operation_number" to revert the operation and uninstall the related packages.

share|improve this answer

Maybe the user himself doesn't know that he installed mysql. It can happen if mysql is a dependency of some other program. Have a look at the package manager logfile, ex: for a redhat check /var/log/yum.log. You will probably find some more packages installed at the same time. You can then deduce what the user wanted to do, and maybe you also want to remove some other packages too that you weren't aware of the installation!

share|improve this answer

protected by Community Jun 26 '13 at 3:21

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.