dbconfession dbconfession - 1 month ago 20
MySQL Question

MySQL from OSX Terminal

I seem to be missing something as all of the tutorials that show how to run MySQL from OSX's command line aren't working.

I can turn the MySQL Server status on and off via System preferences, but if I follow one of the tutorial that shows how to run from the command line using

sudo mysqld_safe
it returns the
sudo: mysqld: command not found


I've also tried logging into MySQL using
mysql -u root -p
and I get
bash: mysql: command not found


/usr/local/mysql/bin/
does exist I just feel like something wasn't installed properly on the client side. Any help figuring out how to access mysql from the terminal would be very much appreciated. Thanks in advance.

Answer

/usr/local/mysql/bin is not in the default $PATH. $PATH is the list of directories that are searched when you try to use an executable without specifying a complete path.

You either need to use the full path (/usr/local/mysql/bin/mysql_executable_here) or add it to your $PATH:

export PATH="$PATH:/usr/local/mysql/bin"

You can add this line to a file called .profile in your home directory to execute it each time you create a new shell:

echo 'export PATH="$PATH:/usr/local/mysql/bin"' >> ~/.profile
source ~/.profile