Pragmatism in the real world

Uninstalling MySQL on Mac OS X Leopard

To uninstall MySQL and completely remove it (including all databases) from your Mac do the following:

  • Use mysqldump to backup your databases to text files!
  • Stop the database server
  • sudo rm /usr/local/mysql
  • sudo rm -rf /usr/local/mysql*
  • sudo rm -rf /Library/StartupItems/MySQLCOM
  • sudo rm -rf /Library/PreferencePanes/My*
  • edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
  • rm -rf ~/Library/PreferencePanes/My*
  • sudo rm -rf /Library/Receipts/mysql*
  • sudo rm -rf /Library/Receipts/MySQL*
  • sudo rm -rf /private/var/db/receipts/*mysql*

The last three lines are particularly important as otherwise, you can’t install an older version of MySQL even though you think that you’ve completely deleted the newer version!

79 thoughts on “Uninstalling MySQL on Mac OS X Leopard

  1. I had been struggling over my install for a while, and thanks to this post I was able to start over. Thank you so very much!

  2. Thanks a lot! This is the only source I've found with great instructions on removing MySQL installs.

  3. Holy cow, thanks! Somehow the root account got screwed up and had to reinstall, this was perfect.

  4. Hi Rob,
    After hunting high and low on the web, I came across your website. Great to find somebody that can write clearly and plainly about techie issues.

    Wonder if you can help me? I'm using Tiger V10.4.11, and after several disastrous attempts to install MySQL on my Mac before discovering MAMP, I followed your steps above. I then installed MAMP and my Apache server works fine but the MySQL server fails to start. Question is – should I move to Leopard (and would this solve my problems) or is there something else peculiar to Tiger that I have to do…
    Yours baffled
    Jacqui

  5. At least I can have another attempt at MySQL on OS X without having to do a complete reinstall.

  6. Thank you for posting this; it helped me out. A couple of small things I noticed while running through the steps (OS X 10.5.7 / MySQL 5.1.34 x86_64 Pkg):
    1. If you chose to install mySQL for 'this user only' then you'll want to delete the MySQL.prefPane directory from ~/Library/PreferencePanes rather than the system /Library/PreferencePanes.
    2. The /usr/local directory doesn't exist with a default OS X installation. Provided that you haven't installed other applications that use it (check this first!), you can remove the entire /usr/local (rm -rf /usr/local).
    3. I did notice that mySQL will create /usr/local if it doesn't exist, and /usr/local/include (though it is left empty), and /usr/local/lib with some Pkg directive that can be removed as well.

  7. Thank You for sharing your wisdom
    I hope this gets me back up and running so that i can sleep….

    Brett

  8. Thanks for the tips, Rob – much appreciated.

    Just one note, possibly related to my problematic mySQL install (from package), there was nothing related to change in my /etc/hostconfig (10.5.7, mysql-5.1.35-osx10.5-x86_64)

  9. Please tell me what I am doing wrong
    nosike-adahs-macbook:~ nosikeadah$ ls
    Desktop Downloads Movies Pictures Sites
    Documents Library Music Public
    nosike-adahs-macbook:~ nosikeadah$ cd Library/
    nosike-adahs-macbook:Library nosikeadah$ ls
    Address Book Plug-Ins Keychains
    Application Support LaunchAgents
    Application Support:Adobe:Acrobat Logs
    Assistants Mail
    Audio Phones
    Autosave Information PreferencePanes
    Caches Preferences
    Calendars Printers
    ColorPickers PubSub
    ColorSync Receipts
    Compositions Safari
    Cookies Screen Savers
    Documentation Sounds
    Favorites Spelling
    FontCollections Thunderbird
    Fonts Voices
    Input Methods iMovie
    Internet Plug-Ins iTunes
    Keyboard Layouts
    nosike-adahs-macbook:Library nosikeadah$ cd local
    -bash: cd: local: No such file or directory
    nosike-adahs-macbook:Library nosikeadah$ cd /usr
    nosike-adahs-macbook:usr nosikeadah$ ls
    X11 bin libexec sbin standalone
    X11R6 lib local share
    nosike-adahs-macbook:usr nosikeadah$ cd local
    nosike-adahs-macbook:local nosikeadah$ ls
    mysql-5.0.83-osx10.5-x86
    nosike-adahs-macbook:local nosikeadah$ ls
    mysql-5.0.83-osx10.5-x86
    nosike-adahs-macbook:local nosikeadah$ cd mysql-5.0.83-osx10.5-x86/
    nosike-adahs-macbook:mysql-5.0.83-osx10.5-x86 nosikeadah$ ls
    COPYING configure man support-files
    EXCEPTIONS-CLIENT data mysql-test tests
    INSTALL-BINARY docs scripts
    README include share
    bin lib sql-bench
    nosike-adahs-macbook:mysql-5.0.83-osx10.5-x86 nosikeadah$ cd ..
    nosike-adahs-macbook:local nosikeadah$ cd ..
    nosike-adahs-macbook:usr nosikeadah$ cd ..
    nosike-adahs-macbook:/ nosikeadah$ cd ..
    nosike-adahs-macbook:/ nosikeadah$ cd ..
    nosike-adahs-macbook:/ nosikeadah$ sudo rm /usr/local/mysql
    Password:
    nosike-adahs-macbook:/ nosikeadah$ sudo rm -rf/usr/local/mysql*
    Password:
    nosike-adahs-macbook:/ nosikeadah$ sudo rm /usr/local/mysql
    Password:
    rm: /usr/local/mysql: No such file or directory
    nosike-adahs-macbook:/ nosikeadah$ ls
    Applications Volumes net
    Desktop DB bin private
    Desktop DF cores sbin
    Library dev tmp
    Network etc usr
    System home var
    User Guides And Information mach_kernel
    Users mach_kernel.ctfsys
    nosike-adahs-macbook:/ nosikeadah$ usr
    -bash: usr: command not found
    nosike-adahs-macbook:/ nosikeadah$ cd usr
    nosike-adahs-macbook:usr nosikeadah$ ls
    X11 bin libexec sbin standalone
    X11R6 lib local share
    nosike-adahs-macbook:usr nosikeadah$ cd local
    nosike-adahs-macbook:local nosikeadah$ ls
    mysql-5.0.83-osx10.5-x86
    nosike-adahs-macbook:local nosikeadah$ cd mysql-5.0.83-osx10.5-x86/
    nosike-adahs-macbook:mysql-5.0.83-osx10.5-x86 nosikeadah$ ls
    COPYING configure man support-files
    EXCEPTIONS-CLIENT data mysql-test tests
    INSTALL-BINARY docs scripts
    README include share
    bin lib sql-bench
    nosike-adahs-macbook:mysql-5.0.83-osx10.5-x86 nosikeadah$ cd lib
    nosike-adahs-macbook:lib nosikeadah$ ls
    libdbug.a libmysqlclient_r.15.dylib libndbclient.a
    libmygcc.a libmysqlclient_r.a libndbclient.dylib
    libmysql.imp libmysqlclient_r.dylib libndbclient.la
    libmysqlclient.15.dylib libmystrings.a libz.a
    libmysqlclient.a libmysys.a
    libmysqlclient.dylib libndbclient.2.dylib
    nosike-adahs-macbook:lib nosikeadah$ cd ..
    nosike-adahs-macbook:mysql-5.0.83-osx10.5-x86 nosikeadah$ cd bin
    nosike-adahs-macbook:bin nosikeadah$ ls
    CMakeLists.txt mysqld_multi
    comp_err mysqld_safe
    comp_sql.c mysqldump
    make_sharedlib_distribution mysqldumpslow
    msql2mysql mysqlhotcopy
    my_print_defaults mysqlimport
    myisam_ftdump mysqlmanager
    myisamchk mysqlshow
    myisamlog mysqltest
    myisampack mysqltestmanager
    mysql mysqltestmanager-pwgen
    mysql_client_test mysqltestmanagerc
    mysql_config ndb_config
    mysql_convert_table_format ndb_cpcd
    mysql_explain_log ndb_delete_all
    mysql_find_rows ndb_desc
    mysql_fix_extensions ndb_drop_index
    mysql_fix_privilege_tables ndb_drop_table
    mysql_fix_privilege_tables_sql.c ndb_error_reporter
    mysql_secure_installation ndb_mgm
    mysql_setpermission ndb_mgmd
    mysql_tableinfo ndb_restore
    mysql_tzinfo_to_sql ndb_select_all
    mysql_upgrade ndb_select_count
    mysql_upgrade_shell ndb_show_tables
    mysql_waitpid ndb_size.pl
    mysql_zap ndb_test_platform
    mysqlaccess ndb_waiter
    mysqlaccess.conf ndbd
    mysqladmin perror
    mysqlbinlog replace
    mysqlbug resolve_stack_dump
    mysqlcheck resolveip
    mysqld safe_mysqld
    mysqld-debug
    nosike-adahs-macbook:bin nosikeadah$ sudo rm mysql
    nosike-adahs-macbook:bin nosikeadah$ sudo rm -rf mysql*
    nosike-adahs-macbook:bin nosikeadah$ sudo rm -rf mysql*
    nosike-adahs-macbook:bin nosikeadah$ sudo rm /usr/local/mysql
    rm: /usr/local/mysql: No such file or directory
    nosike-adahs-macbook:bin nosikeadah$ sudo rm /usr/local/mysqlmysql-5.0.83-osx10.5-x86/
    rm: /usr/local/mysqlmysql-5.0.83-osx10.5-x86/: No such file or directory
    nosike-adahs-macbook:bin nosikeadah$ sudo rm /usr/local/mysql-5.0.83-osx10.5-x86/
    rm: /usr/local/mysql-5.0.83-osx10.5-x86/: is a directory
    nosike-adahs-macbook:bin nosikeadah$ cd ..
    nosike-adahs-macbook:mysql-5.0.83-osx10.5-x86 nosikeadah$ cd ..
    nosike-adahs-macbook:local nosikeadah$ cd ..
    nosike-adahs-macbook:usr nosikeadah$ cd ..
    nosike-adahs-macbook:/ nosikeadah$ cd ..
    nosike-adahs-macbook:/ nosikeadah$ sudo rm /usr/local/mysql-5.0.83-osx10.5-x86/
    rm: /usr/local/mysql-5.0.83-osx10.5-x86/: is a directory
    nosike-adahs-macbook:/ nosikeadah$ sudo rm /usr/local/mysql-5.0.83-osx10.5-x86
    rm: /usr/local/mysql-5.0.83-osx10.5-x86: is a directory
    nosike-adahs-macbook:/ nosikeadah$ sudo rm -rf/usr/local/mysql-5.0.83-osx10.5-x86*
    rm: illegal option — /
    usage: rm [-f | -i] [-dPRrvW] file …
    unlink file
    nosike-adahs-macbook:/ nosikeadah$ sudo rm -rf/usr/local/mysql-5.0.83-osx10.5-x86*
    rm: illegal option — /
    usage: rm [-f | -i] [-dPRrvW] file …
    unlink file
    nosike-adahs-macbook:/ nosikeadah$ sudo rm -rf/Library/StartupItems/MYSQLCOM
    rm: illegal option — /
    usage: rm [-f | -i] [-dPRrvW] file …
    unlink file
    nosike-adahs-macbook:/ nosikeadah$ sudo rm -rf/Library/PreferencePane/My*
    rm: illegal option — /
    usage: rm [-f | -i] [-dPRrvW] file …
    unlink file
    nosike-adahs-macbook:/ nosikeadah$ edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
    nosike-adahs-macbook:/ nosikeadah$

  10. Nosike,
    Try a space after the -rf:


    sudo rm -rf /usr/local/mysql-5.0.83-osx10.5-x86*
    sudo rm -rf /Library/StartupItems/MYSQLCOM
    sudo rm -rf /Library/PreferencePane/My*

    Regards,

    Rob…

  11. 1.Thanks for the tip. I just have some more questions like how do I know it has worked?
    2. After the first line I typed, I was asked for my password which I gave. Does this happen? The below is the result I got:
    nosike-adahs-macbook:/ nosikeadah$ sudo rm -rf /usr/local/mysql-5.0.83-osx10.5-x86*
    Password:
    nosike-adahs-macbook:/ nosikeadah$ sudo rm -rf /Library/StartupItmes/MYSQLCOM
    nosike-adahs-macbook:/ nosikeadah$ sudo rm -rf /Library/PreferencePane/My*
    nosike-adahs-macbook:/ nosikeadah$ edit /etc/hostconfig
    nosike-adahs-macbook:/ nosikeadah$ sudo rm -rf /Library/Receipts/mysql*
    nosike-adahs-macbook:/ nosikeadah$ sudo rm -rf /Library/Receipts/MySQL*
    nosike-adahs-macbook:/ nosikeadah$

  12. As it's *nix, you know that it's worked by the absence of error messages!

    sudo will ask for a password, so that's expected. It remembers it for a while which is why you don't have to keep giving it.

    Looks like you succeeded :)

    Regards,

    Rob…

  13. Also when I was editing hostconfig, the line:
    MYSQLCOM=-YES- which you said should be deleted was this: MYSQLCOM=-NO- on my version of hostconfig but I still deleted that line anyway. I hope i have not done anything wrong

  14. Thank you very much for the help. It was very helpful. Now I can install it again thanks. By the way, I would like to know if you give tips for installing MySQL 5 on the leopard. I hope am not pushing my luck :-)

    Thanks again ROB.

  15. Please can anyone help me with the steps to install MySQL 5.0 for leopard?

    Thanks

  16. Helpful, but may I point out that you missed out the preference pane folder in "USERNAME/Library/PreferencePanes/". Some people install them just for a specific user.

  17. Hi thanks for the exact help that i was looking for :)
    But when i again tried to reinstall it from .dmg file it installed but i wasn't able to connect it, it says socket
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    Can you help me out in it ASAP??

  18. Hi,

    I'm trying to uninstall MySQL using these commands but when I reach this line:

    edit /etc/hostconfig and remove the line MYSQLCOM=-YES-

    I get this message: -bash: edit: command not found

    I then tried to find where it is (whereis edit) but nothing happens.

    Can you help me please? Thank you!

  19. Sofia,

    Edit is an instruction, not a command. Having said that, if you install TextWrangler's command line tool, then you will have an "edit" command in terminal.

    Regards,

    Rob…

  20. Thanks for the information first

    But have a MAJOR issue here

    1 I have a back up in my "Time Machine" So I know it's all backed up somewhere
    2 I upgraded to 10.6 so all went smoothly
    3 Until I went to check mySQL where my Cold Fusion is called it, This is where the issues arose

    Cold Fusion is working not an issue I did a simple "hello"
    But when I ran mysql to check the db I got an error

    so I followed the instructions listed above and REMOVED the old sql and installed the new db

    NOW I discover ALL my old Databases ARE GONE

    How do I get it back?

    I have like I said "Time Machine" but where are my file to move them back?

    I attemped to move

    to move the files from the "Time Machine" from /usr/local/mysql back to my machine in 10.6 but the old mysql is NOT compatible

    I was thinking I could reinstall the old mysql but which file contain the data files that I can just pick up and move back to my machine or is this really possible?

  21. ron,

    I would expect that you will find the data is in /usr/local/mysql4.0.67-osx10.5-x86_64/data.

    (shift+cmd+g is useful in finder to go to the folder, or navigate via Terminal and then do "open .")

    However, I suspect that to change major versions, you would need to do a mysqldump to convert the data to text format. http://dev.mysql.com/doc/refman/5.1/en/upgrade.html may help.

    Regards,

    Rob…

  22. Rob

    thanks… converting was too complicated

    I used the time back up on the mac went back to 4.0 mysql on my computer did a data dump as you mention then used time back up on the mac again and went back to 5.0 and took the data back in and worked great

    thanks :)

  23. Hi,

    I have installed MySQL6 and as it won't run I tried to use MySQL5. After all these steps to delete all MySQL entries from the disk I still will not be able to install the MySQL5 version. The installed tells me, that there is still a new version of MySQL an the system and it will not continue.

    How does the installed knows that?

    Regards,

    Dirk

  24. Hi all,

    I've found the reason in an other blog.

    If you've installed MySQL 5.4.1 (or higher) you will also have to remove any *mysql* preference files from here:

    /private/var/db/receipts/

    …as well as any other receipts folder mentioned above.

  25. You might want to add the following two lines to the beginning of the process:
    "# Back up all your databases ( just in case ;)"
    "sudo kill `sudo cat /usr/local/mysql/data/${HOSTNAME}.pid`"

    This will gracefully kill mysqld if it is running. "ps -u mysql" should display a process if it is running.

  26. I have a problem with:
    edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
    after i hit enter it says
    -bash: edit: command not found

    everything else works great
    but because that one command doesn't work, it doesn't successfully uninstall mysql.
    please heeelpppp

  27. Hi,

    I downloaded Mac OS X 10.5 (x86, 64-bit), DMG Archive from http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg
    and having a bit of a problem. Installation went fine, but when trying to start it, I get this:

    Error
    Could not startup MySQL server
    Reason 255

    Is there any chance that the version I downloaded, and/or its specific mirror was faulty? Double checked my comp display, and it's 32 bit. Should I have downloaded the 32 bit version?

    Thank you.

  28. I've followed these instructions, but for some reason I have a directory: usr/local/mysql-5.5.0-m2-osx10.6-x86 which has multiple (more than 30) identical, empty directories within it.

    I've tried deleting it using your:
    sudo rm -rf /usr/local/mysql*
    command, but it will not delete…

    At the moment I can't re-install MySql because of this folder.

    Any tips on how I can get around this?

    Thanks!

  29. Helped, but I did have to also delete the following:

    /private/var/db/receipts/com.mysql.mysql.bom
    /private/var/db/receipts/com.mysql.mysql.plist
    /private/var/db/receipts/com.mysql.mysqlstartup.bom
    /private/var/db/receipts/com.mysql.mysqlstartup.plist

    Once I did that I was able to install an older version.

  30. Thanks! Worked for me in Snow Leopard. Added this line, as well:

    sudo rm -rf /var/db/receipts/com.mysql.*

  31. Thank you so much for this info! Somehow info on uninstalling MySQL from OSX is "hard" to find. This worked perfert!

  32. I am a newbie, can someone please tell me where this hostconfig file is located that I need to edit?

    /etc/hostconfig and remove the line MYSQLCOM=-YES-

    I cannot find it with spotlight.

    Is this file invisible?

  33. /etc/hostconfig is at the "root" level because there is "/" a the start of "/etc/hostconfig"…

    The command "cat /etc/hostconfig"

    give:

    # This file is going away

    AFPSERVER=-NO-
    AUTHSERVER=-NO-
    AUTOMOUNT=-YES-
    NFSLOCKS=-AUTOMATIC-
    NISDOMAIN=-NO-
    TIMESYNC=-NO-
    QTSSERVER=-NO-
    WEBSERVER=-NO-
    SMBSERVER=-NO-
    SNMPSERVER=-NO-
    MYSQLCOM=-NO-

  34. Please add this line at the end:

    sudo rm -rf /var/db/receipts/com.mysql.*

    It will enable the ability to install a previous version of my SQL.
    Great job

  35. Great information!

    but where to find : edit /etc/hostconfig and remove the line MYSQLCOM=-YES-

  36. bogon:~ dwang$ cd /usr/local
    bogon:local dwang$ ls
    bin mysql-5.1.54-osx10.6-x86
    juniper mysql-5.5.8-osx10.6-x86
    mysql
    bogon:local dwang$

    after I successfully install a early version. I find 5.5.8 still there .Rob what is my mistake?

  37. Hi,

    I had earlier installed mysql-5.1.50-osx10.6-x86_64.dmg and then uninstalled it using the below belo command (found in stackoverflow)

    $ sudo rm /usr/local/mysql
    Password:
    $ sudo rm -rf /usr/local/mysql*
    $ sudo rm -rf /Library/StartupItems/MySQLCOM
    $ sudo rm -rf /Library/PreferencePanes/My*
    $ rm -rf ~/Library/PreferencePanes/My*
    $ sudo rm -rf /Library/Receipts/mysql*
    $ sudo rm -rf /Library/Receipts/MySQL*
    $ sudo vi /etc/hostconfig
    $ sudo rm -rf /var/db/receipts/com.mysql.mysql*

    Then I have tried to reinstall from mysql-5.5.9-osx10.6-x86_64.dmg.

    However I am getting the below error:

    The installation failed The installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.

    Any help will be highly appreciated.

  38. Like some of the others, I also had to remove these receipts

    sudo rm /var/db/receipts/com.mysql.mysql*
    sudo rm /private/var/db/receipts/com.mysql*

  39. If you've installed MySQL 5.4.1 (or higher) you will also have to remove any *mysql* preference files from here:

    /private/var/db/receipts/

  40. instead of …
    edit /etc/hostconfig
    try …
    vim /etc/hostconfig
    or …
    open -e /etc/hostconfig
    but the last method usually (always) encounters permission errors

  41. I found I also had to delete the following after I installed MySQL Community Edition 5.5 and then wanted to revert to 5.1

    /private/var/db/receipts/com.mysql.mysql.bom
    /private/var/db/receipts/com.mysql.mysql.plist
    /private/var/db/receipts/com.mysql.mysqlstartup.bom
    /private/var/db/receipts/com.mysql.mysqlstartup.plist

  42. Confirming Hugh Miles' finding, 5.5 creates extra .plist and .bom files in /private/var/db/receipts/

    sudo rm -rf /private/var/db/receipts/com.mysql.mysql*

  43. Please update with the following:

    sudo rm -rf /private/var/db/receipts/*mysql*

    This is required for v5.4.1 or higher. Without this I could not reinstall as the installer insisted that there was a newer version installed.

    Thanks for the help.

  44. hi, i could not do the line where it says edit /etc/hostconfig and remove the line MYSQLCOM=-YES, i just can't find that file…does that affect my uninstallation big time? how can i remove the MySQL icon in System Preferences window? Apart from that, I guess all is fine with my uninstallation! Thanks for your virtual presence!:-)

  45. These instructions were a great help, but I've noticed that some installations (macports?) put mysql-related files in /opt, and fink (apparently) puts them in /sw/fink

Comments are closed.