1

How do I use MySQL from the CLI? When I use the terminal, I get:

Darrens-MacBook-Pro:~ thufir$ 
Darrens-MacBook-Pro:~ thufir$ mysql
-bash: mysql: command not found
Darrens-MacBook-Pro:~ thufir$ 

As you can see, MySQL is installed and running:

enter image description here

this system:

System Software Overview:

  System Version:   OS X 10.10.2 (14C1510)
  Kernel Version:   Darwin 14.1.0
  Boot Volume:  Mac OSx
  Boot Mode:    Normal
  Computer Name:    A MacBook Pro
  User Name:    thufir (thufir)
  Secure Virtual Memory:    Enabled
  Time since boot:  2:08
0

1 Answer 1

3

The Oracle installer for MySQL puts the mysql binary in /usr/local/mysql/bin. You either need to call it with the full path:

/usr/local/mysql/bin/mysql

Or put /usr/local/mysql/bin in your PATH by adding the following to end of your ~/.bash_profile:

export PATH=/usr/local/mysql/bin:${PATH}

And then reloading your shell.

See my answer to this question for why I think you should install these things with Homebrew instead of dmg-based installers. Ultimately, it lets you manage what's in your PATH with less hassle.

2
  • my question is why the dmg installer doesn't just add mysql to the path...coming from Linux, that seems broken.
    – Thufir
    Commented Mar 28, 2015 at 4:05
  • It's generally not the case that dmg-based installers on OS X modify your PATH. There's a very "don't do unexpected things to user's environments" ethos to installer packages on OS X.
    – Ian C.
    Commented Mar 28, 2015 at 4:06

Not the answer you're looking for? Browse other questions tagged .