The line to make this permanent change is: echo 'export PATH=$PATH:/usr/local/mysql/bin' > ~/.bash_profile bash_profile which is a dotfile.ĭotfiles are hidden files/folders used to store user preferences and customise your system.bash_profile is one of them and the one we need to update for the change to happen every time you load Terminal. To make sure the new configuration is loaded every time you open Terminal you need to update the. The issue with assigning the new path is that when you close the Terminal all changes are loss just like closing an unsaved file. Mine returns: mysql Ver 8.0.18 for macos10.14 on x86_64 (MySQL Community Server - GPL) You should get your version of MySQL popping up. Try typing this into the Terminal and see what comes up: mysql -version The $PATH is the variable and the colon : assigns the new location for the /bin folder so now when you type in msql in the command line it works as it links up both. We can do that by typing the following line into Terminal: export PATH=$PATH:/usr/local/mysql/bin Installing MySQL directly doesn’t seem to do this for you. When you install new packages most of the time they live in the /bin directory and the $PATH variable is updated to know where to look for them. In the /bin folder lives executable files and packages. The $PATH variable is where the Terminal looks up for any command in the /bin folder. Writing just MySQL in Terminal doesn’t work because Terminal looks for commands that are stored in the $PATH variable. Recently, I had compatibility issues with installing the latest MySQL on High Sierra and wrote a post on how to install one that was compatible. It should execute the right files and the Terminal should return your version of MySQL. Therefore if you typed into Terminal something like: /usr/local/mysql/bin/mysql -version Therefore you have to manually connect the mysql command with the MySQL package location which is located in /usr/local/mysql/bin/mysql. You may have gotten something like mysql command not found in response. You may have tried typing something like this into the Terminal: mysql -version Specifically, if you’ve installed it on an older operating system like High Sierra. You would think installing MySQL automatically does this but it doesn’t I’ve found if you don’t install MySQL via Brew or Pip, using mysql in command line doesn’t work straight out of the box. Here I am going to talk you through how to use the mysql command in the terminal.
0 Comments
Leave a Reply. |