{"id":3295,"date":"2017-05-11T10:41:08","date_gmt":"2017-05-11T10:41:08","guid":{"rendered":"http:\/\/www.nikola-breznjak.com\/blog\/?p=3295"},"modified":"2017-05-11T10:46:07","modified_gmt":"2017-05-11T10:46:07","slug":"stop-remove-mysql-server-mac-keep-client","status":"publish","type":"post","link":"https:\/\/nikola-breznjak.com\/blog\/quick-tips\/stop-remove-mysql-server-mac-keep-client\/","title":{"rendered":"How to stop and remove MySQL server on a Mac but keep the client"},"content":{"rendered":"<h2>Remove MySQL server on a Mac<\/h2>\n<p>The other day I wanted to run some project via Docker Compose. Surprisingly, the MySQL service defined normally like this:<\/p>\n<pre><code>mysql:\n       image: tutum\/mysql\n       env_file:\n         - docker.env\n       ports:\n         - \"3306:3306\"\n<\/code><\/pre>\n<p>didn&#8217;t start, because I apparently had MySQL server already running locally.<\/p>\n<p>Trust me, I tried everything from <a href=\"http:\/\/stackoverflow.com\/questions\/11091414\/how-to-stop-mysqld\/11091462\">this StackOverflow post<\/a> but any time I tried to kill the process (that I saw is running with <code>ps aux | grep mysql<\/code>) it would spun back up.<\/p>\n<p>Then, I remembered that I installed MySQL server some time ago via the app called MAMP. I went in and removed all of that and also I found <a href=\"https:\/\/gist.github.com\/vitorbritto\/0555879fe4414d18569d\">one post<\/a> that I&#8217;ll paste here (full credit to <a href=\"https:\/\/gist.github.com\/vitorbritto\">Vitor Britto<\/a>):<\/p>\n<pre><code># Remove MySQL completely\n\n1. Open the Terminal\n2. Use `mysqldump` to backup your databases\n3. Check for MySQL processes with: `ps -ax | grep mysql`\n4. Stop and kill any MySQL processes\n5. Analyze MySQL on HomeBrew: \n\n    ```\n    brew remove mysql\n    brew cleanup\n    ```\n\n6. Remove files: \n\n    ```\n    sudo rm \/usr\/local\/mysql\n    sudo rm -rf \/usr\/local\/var\/mysql\n    sudo rm -rf \/usr\/local\/mysql*\n    sudo rm ~\/Library\/LaunchAgents\/homebrew.mxcl.mysql.plist\n    sudo rm -rf \/Library\/StartupItems\/MySQLCOM\n    sudo rm -rf \/Library\/PreferencePanes\/My*\n    ```\n\n7. Unload previous MySQL Auto-Login: \n\n    ```\n    launchctl unload -w ~\/Library\/LaunchAgents\/homebrew.mxcl.mysql.plist\n    ```\n\n8. Remove previous MySQL Configuration: \n\n    ```\n    subl \/etc\/hostconfig` \n    # Remove the line MYSQLCOM=-YES-\n    ```\n\n9. Remove previous MySQL Preferences: \n\n    ```\n    rm -rf ~\/Library\/PreferencePanes\/My*\n    sudo rm -rf \/Library\/Receipts\/mysql*\n    sudo rm -rf \/Library\/Receipts\/MySQL*\n    sudo rm -rf \/private\/var\/db\/receipts\/*mysql*\n    ```\n\n10. Restart your computer just to ensure any MySQL processes are killed\n11. Try to run mysql, **it shouldn't work**\n<\/code><\/pre>\n<h2>Keep the MySQL client for interacting with the MySQL databases<\/h2>\n<p>At this point, I removed everything related to MySQL, but I still needed the client to connect to the MySQL database that I ran with Docker Compose.<\/p>\n<p>The fastest way (that I&#8217;ve found in <a href=\"http:\/\/stackoverflow.com\/questions\/30990488\/how-do-i-install-command-line-mysql-client-on-mac\">this StackOverflow post<\/a>) to install the client without installing the server was to install <a href=\"https:\/\/www.mysql.com\/products\/workbench\/\">MySQLWorkbench<\/a> and then add this to your path (I put these in my <code>.zshrc<\/code> file; you may use <code>.bashrc<\/code>):<\/p>\n<pre><code>export PATH=$PATH:\/Applications\/MySQLWorkbench.app\/Contents\/MacOS\n<\/code><\/pre>\n<p><em>Of course, the path may vary for you in case you&#8217;ve installed it in some other location. Anyway, hope this helps someone&#8230; ?<\/em><\/p>\n<blockquote class=\"twitter-tweet\" data-width=\"550\">\n<p lang=\"en\" dir=\"ltr\">How to stop and remove <a href=\"https:\/\/twitter.com\/hashtag\/MySQL?src=hash\">#MySQL<\/a> server on a Mac but keep the client <a href=\"https:\/\/t.co\/0vtuBgOqMD\">https:\/\/t.co\/0vtuBgOqMD<\/a><\/p>\n<p>&mdash; Nikola Bre\u017enjak (@HitmanHR) <a href=\"https:\/\/twitter.com\/HitmanHR\/status\/862619388956086272\">May 11, 2017<\/a><\/p><\/blockquote>\n<p><script async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Remove MySQL server on a Mac The other day I wanted to run some project via Docker Compose. Surprisingly, the MySQL service defined normally like this: mysql: image:&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3296,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-3295","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-quick-tips"],"_links":{"self":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/3295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/comments?post=3295"}],"version-history":[{"count":3,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/3295\/revisions"}],"predecessor-version":[{"id":3300,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/3295\/revisions\/3300"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media\/3296"}],"wp:attachment":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media?parent=3295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/categories?post=3295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/tags?post=3295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}