This short tutorial shows how to install MySQL on a Mac using Homebrew and how to verify it is running using Sequel Pro. Install Homebrew. Homebrew is a package manager for Mac and serves a. Jan 08, 2020 To update to the latest version, we will use the Homebrew Package manager. It is one of the best and convenient methods to install Python on macOS. To know more about Homebrew Package manager, visit here. Download and install Homebrew Package Manager. If you don’t have homebrew installed on your system, follow the steps below.

Installing MySQL on MacOS with Homebrew

Mysql homebrew install php

Looks like the prior installation of mysql8 created bad DB files, which must be deleted manually: rm -rf /usr/local/var/mysql # WARNING: this deletes all your data! Brew uninstall [email protected] brew install [email protected] Note: this solution is intended to repair fresh installations only. It potentially results in loss of data. In this tutorial we will learn how to install MySQL (via Homebrew (This is much faster and more easier then in. Brew remove mysql; brew cleanup (note that this command will clean up after more than just MySQL) Remove if present: /usr/local/var/mysql; Reinstalling. Select the version that you want to install (in my case, 5.5.x) brew tap homebrew/versions; brew install mysql55; Follow the post-install instructions as provided by the brew install output.

I was trying to install MySQL on MacOS and I followed the instructions to install it via Homebrew:

$ brew install mysql

Pretty easy, but then as I worked along I screwed something up where I could not load mysql in the command line. I would get the following error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

So I do the logical step of uninstalling and reinstalling:

$ brew uninstall mysql
$ brew install mysql

Homebrew Install Mysql 5.7

I still get the same error. Two hours of browsing StackOverflow later, I figured it out. I failed to notice the following errors during reinstallation:

2019-02-21T01:02:48.455076Z 0 [System] [MY-013169] [Server] /usr/local/Cellar/mysql/8.0.15/bin/mysqld (mysqld 8.0.15) initializing of server in progress as process 18070
2019-02-21T01:02:48.457920Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2019-02-21T01:02:48.457929Z 0 [ERROR] [MY-013236] [Server] Newly created data directory /usr/local/var/mysql/ is unusable. You can safely remove it.
2019-02-21T01:02:48.457994Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-02-21T01:02:48.458203Z 0 [System] [MY-010910] [Server] /usr/local/Cellar/mysql/8.0.15/bin/mysqld: Shutdown complete (mysqld 8.0.15) Homebrew.

This is the key line:
Newly created data directory /usr/local/var/mysql/ is unusable. You can safely remove it.

What do I do? Remove that directory!

$ sudo rm -rf /usr/local/var/mysql/

Then run the post install script:

$ brew postinstall mysql

And voilà, mysql loads!

$ mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 8
Server version: 8.0.15 Homebrew

Learn from my fail.

Question or issue on macOS:

I want to install the MySQL client for the command line, not a GUI. I have searched over the web but only found instructions on installing the MySQL server.

How to solve this problem?

Solution no. 1:

install MySQLWorkbench, then

Solution no. 2:

If you have already installed MySQL from the disk image (dmg) from http://dev.mysql.com/downloads/), open a terminal, run:

then, reload .bash_profile by running following command:

You can now use mysql to connect to any mysql server:

Credit & Reference: http://www.gigoblog.com/2011/03/13/add-mysql-to-terminal-shell-in-mac-os-x/

Solution no. 3:

Best option is:

Solution no. 4:

Mysql has a client-only set of utilities:

Mysql client shell
https://dev.mysql.com/downloads/shell/

Other command line utilities
https://dev.mysql.com/downloads/utilities/

Mac OSX version available.

Solution no. 5:

This strictly installs a command line client, without the other overhead:

Install Homebrew (if you don’t have it):

Then, install mysql-client:

Then, add the mysql-client binary directory to your PATH:

Finally, reload your bash profile:

Then you should be able to run mysql in a terminal, if not try opening a new terminal

Solution no. 6:

There is now a mysql-client formula.

brew install mysql-client

Solution no. 7:

For installing mysql-shell with homebrew, run

you can then launch the mysql shell with

if you want to enter SQL mode directly, run

Solution no. 8:

Open the “MySQL Workbench” DMG file and

Eject the DMG disk

Solution no. 9:

If you installed from the DMG on a mac, it created a mysql client but did not put it in your user path.

Add this to your .bash_profile:

Homebrew Install Mysql 5.7

This will let you run mysql from anywhere as you.

Mysql Homebrew Install Mac

Solution no. 10:

Installation command from brew:

Look at what you can do:

Run query from mysqlsh client installed:

Hope this helps!