I cant get my mysql to start on os x 10.7. It is located in /usr/local/mysql/bin/mysql
I get command not found when I type mysql --version
in the terminal.
I tried this can't access mysql from command line mac but still get command not found. I tried installing mysql with the dmg and i have tried to install it through homebrew and I cant get it to work. When I try to start mysql with homebrew I get MySQL won't start
This is my $PATH
:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/Users/Victoria/bin:/usr/local//usr/local/mysql/bin/private/var/mysql/private/var/mysql/bin
This question is related to
mysql
Your PATH might not setup. Go to terminal and type:
echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile
Essentially, this allows you to access mysql from anywhere.
Type cat .bash_profile
to check the PATH has been setup.
Check mysql version now: mysql --version
If this still doesn't work, close the terminal and reopen. Check the version now, it should work. Good luck!
With MAMP
You have to set PATH for mysql in your .bashrc
file using following:
export PATH=$PATH:/usr/local/mysql/bin
But If you are using oh my zsh
then you have to add path inside .zshrc
file.
I have tried a lot of the suggestions on SO but this is the one that actually worked for me:
sudo sh -c 'echo /usr/local/mysql/bin > /etc/paths.d/mysql'
then you type
mysql
It will prompt you to enter your password.
It is possible you are using zsh instead of bash then you have to enter the above mentioned commands in .zshenv instead of .bash_profile
in terminal do:
vi ~/.bash_profile
And add this line:
export PATH=${PATH}:/usr/local/mysql/bin
and the type this in terminal:
mysql -u [username] -p [password]
May be i will help out some of you that even though if you are unable to open mysql from terminal after trying changing path in .bash_profile
then you always found the error "MYSQL not found" hence you can use the following command directly it will ask for your password and sql bash is opened
/usr/local/mysql/bin/mysql -u root -p
I installed MAMP and phpmyadmin was working.
But cannot find /usr/local/bin/mysql
This fixed it
sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/local/bin/mysql
Maybe I'll help someone else. None of the above answers worked for Catalina. Finally, this solved the problem
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> /Users/$(whoami)/.bash_profile
Of course, you have to change for the version of mysql you have installed
I had same issue after installing mariadb via HomeBrew, brew doctor
suggested to run brew link mariadb
- which fixed the issue.
If you are using terminal you will want to add the following to ./bash_profile
export PATH="/usr/local/mysql/bin:$PATH"
If you are using zsh, you will want to add the above line to your ~/.zshrc
I faced the same issue, and finally i got a solution. Please go through with the below steps, if you are using MAMP.
This works for me.
Add the following lines in bash_profile:
alias startmysql='sudo /usr/local/mysql/support-files/mysql.server start'
alias stopmysql='sudo /usr/local/mysql/support-files/mysql.server stop'
and save the bash_profile.
Now, in the terminal start and stop the mysql server using the following commands:
startmysql //to start mysql server
and
stopmysql //to stop mysql server
If you installed MySQL Server and you still get
mysql -u root -p command not found
You're most likely experiencing this because you have an older mac version.
Try this:
in the home directory in terminal open -t .bash_profile
paste export PATH=${PATH}:/usr/local/mysql/bin/
inside and save it
instead of writing mysql -u root -p
paste the following in your terminal:
/usr/local/mysql/bin/mysql -u root -p
Enter your password. Now you're in.
Use these two commands in your terminal
alias mysql=/usr/local/mysql/bin/mysql
mysql --user=root -p
Then it will ask you to enter password of your user pc
Enter password:
One alternative way is creating soft link in /usr/local/bin
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
But if you need other executables like mysqldump
, you will need to create soft link for them.
Source: Stackoverflow.com