I'm trying to get mysql up and running on my mac osx 10.9.5. I've installed the latest version14.14
5.6.21
community server. I've gone to system preferences and started the mysql server, then launched terminal and typed this:
/usr/local/mysql/bin/mysql --version
which returns the version, but when I type any type of mysql command I get command not found
. I've also tried sudo mysql_secure_installation
, mysql -u root --password=password
.
I do have web hosting with mysql etc installed, but I want to be able to get to grips with it in the command line first.
You can just modified the .bash_profile
by adding the MySQL $PATH
as the following:
export PATH=$PATH:/usr/local/mysql/bin
.
I did the following:
1- Open Terminal then $ nano .bash_profile
or $ vim .bash_profile
2- Add the following PATH code to the .bash_profile
# Set architecture flags
export ARCHFLAGS="-arch x86_64"
# Ensure user-installed binaries take precedence
export PATH=/usr/local/mysql/bin:$PATH
# Load .bashrc if it exists
test -f ~/.bashrc && source ~/.bashrc
3- Save the file.
4- Refresh Terminal using $ source ~/.bash_profile
5- To verify, type in Terminal $ mysql --version
6- It should print the output something like this:
$ mysql Ver 14.14 Distrib 5.7.17, for macos10.12 (x86_64)
The Terminal is now configured to read the MySQL commands from $PATH
which is placed in the .bash_profile
.
That means /usr/local/mysql/bin/mysql is not in the PATH variable..
Either execute /usr/local/mysql/bin/mysql to get your mysql shell,
or type this in your terminal:
PATH=$PATH:/usr/local/mysql/bin
to add that to your PATH variable so you can just run mysql without specifying the path
You have to create a symlink to your mysql installation if it is not the most recent version of mysql.
$ brew link --force [email protected]
for me the following commands worked:
$ brew install mysql
$ brew services start mysql
modify your bash profile as follows <>$vim ~/.bash_profile export PATH=/usr/local/mysql/bin:$PATH Once its saved you can type in mysql to bring mysql prompt in your terminal.
Source: Stackoverflow.com