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

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


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.

| improve this answer | |
  • my question is why the dmg installer doesn't just add mysql to the path...coming from Linux, that seems broken. – Thufir Mar 28 '15 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. Mar 28 '15 at 4:06

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