You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Using terminal - command not found: mysql

I recently downloaded and started to learn mysql. Mysql Workbench works well and I am learning a lot. A lot of the Mysql documentation refers to CLI commands. When I try any of the mysql commands in terminal, I get the 'command not found: mysql' response.


I can see 'mysql' at usr/local/mysql. I can also see 'mysql-8.0.27-macos11-x86_64' at the same location.


How can I get terminal to respond to mysql commands as shown in Mysql documentation?

MacBook Pro 15″, macOS 12.6

Posted on Feb 23, 2023 4:06 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 23, 2023 8:20 AM

Executables on an Intel Mac would likely be installed in /usr/local/bin by the Oracle installer, or even by the homebrew package manager which also offers mysql. If in doubt, check the Oracle MySQL community documentation.

I downloaded the MySQL community server and looked at the installer package with Suspicious Package. It installs in /usr/local, and the install scripts do not update the user's PATH. I like to call it, "being Oracled."

12 replies
Question marked as Top-ranking reply

Feb 23, 2023 8:20 AM in response to VikingOSX

Executables on an Intel Mac would likely be installed in /usr/local/bin by the Oracle installer, or even by the homebrew package manager which also offers mysql. If in doubt, check the Oracle MySQL community documentation.

I downloaded the MySQL community server and looked at the installer package with Suspicious Package. It installs in /usr/local, and the install scripts do not update the user's PATH. I like to call it, "being Oracled."

Feb 23, 2023 10:32 AM in response to BillyBoyS41

BillyBoyS41 wrote:

I have to learn more about Terminal's 'zshrc config file' and the 'Home' directory. I checked and don't have either one.

You definitely have both. Your home directory is probably the default value "/Users/BillyBoyS41" or whatever your "short user name" is in your login account. The zshrc config file is actually named ".zshrc". Because it starts with a period, it is hidden. You can use "ls -al" to view all files, including hidden ones, in the Terminal. The easiest way to do that in the Finder is to type shift command . Repeat to hide hidden files again.


I don't know of any tutorials. I'm sure there are thousands, I just can't recommend any one in particular. Any such tutorial focused on macOS, Linux, or Unix will work. Anything you need is going to be identical. If you encounter something that works differently in Linux than macOS, then you should probably put that off until later.


Unfortunately, it looks like your environment has already been corrupted by the "homebrew" app. The Developer forums here on the Apple Support Community are just full of people who can't do basic command-line operations due to having their system corrupted by homebrew. And yet, virtually every "how to" post you'll find on the internet starts with "1. Install homebrew". These people aren't doing you any favours.

Feb 23, 2023 5:17 AM in response to BillyBoyS41

Is /usr/local in your PATH?

echo $PATH 

I don't think /usr/local is set by default (/usr/local/bin is).


Whatever you used to install mysql should have adjusted your PATH variable. I don't know why it would choose /usr/local and not /usr/local/bin for the link to the source folder. However, it appears the source was installed there, also.


You can edit your PATH in the .zshrc config file in your Home folder.

export PATH=/usr/local:$PATH


Feb 23, 2023 5:39 AM in response to Barney-15E

Thanks for the quick response.


I used echo $PATH and response was: /usr/local/opt/php@7.4/sbin:/usr/local/opt/php@7.4/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin


Not sure how that happened, but being a newbie, I guess my random activity created that path.


I then used export PATH=/usr/local:$PATH, but echo $PATH still returns the same 
/usr/local/opt/php@7.4/sbin:/usr/local/opt/php@7.4/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

When I checked '/usr/local/opt' directory, there was no 'php@7.4' directory.


Also, should I be using sudo?

Feb 23, 2023 5:39 AM in response to BillyBoyS41

You've installed one or more of the various "package management" or "conda" tools and it has corrupted your environment. Normal solutions to such basic problems will no longer work as your command-line environment is now much more complex. You will need to figure out just what you've installed, and master it.


In the future, be more careful about instructions you see posted on the internet. In my experience, they are wrong much more often than they are right.

Feb 23, 2023 9:20 AM in response to Barney-15E

I have to learn more about Terminal's 'zshrc config file' and the 'Home' directory. I checked and don't have either one. Apparently I'm missing some really basic understanding. Where is a good place to learn about the 'Home' directory and how it works?


I will start by reading thoroughly the Terminal User Guide.


Thank you all for your responses.

Feb 23, 2023 1:26 PM in response to BillyBoyS41

If you see it in the Finder, then you should see it in the Terminal. The Terminal can always show more than the Finder.


I don't know what you mean about "basic names" and "nick names". In Linux/Unix, there exists a UID (User ID) that identifies each user. The root (super user) gets UID 0. Everyone else gets higher numbers. Normal user accounts on a Mac start at UID 501. Your user ID is probably 501.


But people rarely use User IDs. It is more common to reference a "user name", also called a "login name" or sometimes just a "login". Apple calls this a "short user name", because Apple always has to "think different".


Typically a person's login is the first letter of their first name and then their last name. "Sara Lee" would have a login of "slee". Again, Apple needs to just slightly different so Apple defaults this value to your first and last name concatenated together. If "Sara Lee" created an account on a Mac and used the default value, her login would be "saralee". (Old-school Unix greybeards have big hangups on this. None of these values would be acceptable for them. The only valid user login has 3 letters for the first letters of the user's first, middle, and last name. Anything more than 3 letters, for anything really, is an abomination for these folks. Assuming Sara Lee's middle name is "Ann", and she worked on a PDP-11 in 1981, her login would then be "sal".)


Apple also has a concept of a "User Name" as opposed to the "Short User Name". Any of the dialog boxes that pop-up asking for your authentication will default to, and prefer, your "User Name". As in the example above, Sara Lee's "user name" would be "Sara Lee". While this concept also exists in Linux/Unix, it is never used there. The only place it is used on the Mac is on those pop-up authentication dialogs.


The only important value here is the "short user name" which would be "saralee" by default. If you are doing really, really advanced stuff, then you might use that numerical UID value which defaults to 501. Ignore anything else.


Considering that you have already installed homebrew and allowed it to take liberties with your account, there is no way to tell what it has done or changed. It could have changed your Terminal prompt to read something strange which you are interpreting as "basic name" and "nickname". I can't tell you any more than that. Even on Linux, those package manager tools are vile abominations against nature. They are suitable only for short tutorials. Afterwards, they will then wreck your system for years to come.

Feb 23, 2023 1:39 PM in response to etresoft

I opened the .zshrc file from the Finder and changed the text there to 'export PATH=/usr/local:$PATH'


Then, when I entered 'echo $PATH', Terminal returned a new path -- /usr/local:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin


Next when I entered 'mysql -v', Terminal returned 'zsh: permission denied: mysql'.


At least Terminal is now connecting to mysql -- an improvement, I guess.


Since I need a password to connect to mysql, I'm guessing I should try entering 'mysql -p'. Does that make sense?

Using terminal - command not found: mysql

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.